Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Add more test cases in Array, Object

Open
#6 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
testing-qa

Research direction

No test file is named in the issue. Locate the existing tests for String.prototype.includes and compare their assertion style with the proposed Array and Object cases. Run that suite first, then add coverage for the shown conversions and verify the cases pass.

Written by the indexing model from the issue text.

Description

I understand that searchString is not accepted in RegExp. (TypeError exception)

Throwing an exception if the first argument is a RegExp is specified in order to allow future editions to define extensions that allow such argument values.

But it does accept Array and Object through the method toString under the specification.

which are

// array
['this', 'is', 'an', 'array'].toString(); // => 'this,is,an,array'

// object
({'obj': 'obj'}).toString(); // => '[object Object]'

Therefore, I would like to add more test cases

// array
assertEquals('this,is,an,array').includes(['this', 'is']), true);
assertEquals('this,is,an,array').includes(['this', 'is'], 1), false);
assertEquals('this, is, an, array').includes(['this', 'is']), false);

// object
assertEquals(String.prototype.includes.apply({ 'toString': function () { return '[object Object]'; }}, [{'obj': 'obj'}, 0]),  true);

It’s weird if someone input the array or object to the method includes, but it does support.

Dominant language
JavaScript
Stars
70
Forks
10
PR merge metrics
No merged PRs in 30d

Getting set up

We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.