Skip to content

Remove indexOf usage from tests in favor of includes #12586

Closed
@refack

Description

@refack
  • Version: > v4
  • Platform: all
  • Subsystem: test

Since v4 entered maintenance, do you think we can eliminate most of the 433 instances of indexOf from /test/*.js?
Note: The prefered alternative is assert.strictEqual(foo.includes(bar), true)

Each hit should be evaluated whether it's an includes surrogate, or a real indexOf use:

test\addons\repl-domain-abort

  • test.js (1 usage found)

test\async-hooks

  • init-hooks.js (2 usages found)

test\common

  • index.js (1 usage found)

test\disabled

  • test-sendfd.js (1 usage found)

test\doctool

  • test-doctool-html.js (3 usages found)

test\internet

  • test-dns-any.js (1 usage found)
  • test-dns.js (1 usage found)

test\parallel

  • test-buffer-fakes.js (1 usage found)
  • test-buffer-write.js (1 usage found)
  • test-child-process-exec-cwd.js (1 usage found)
  • test-console.js (1 usage found)
  • test-dgram-error-message-address.js (1 usage found)
  • test-domain-top-level-error-handler-throw.js (2 usages found)
  • test-domain-uncaught-exception.js (2 usages found)
  • test-domain.js (1 usage found)
  • test-http-keepalive-maxsockets.js (1 usage found)
  • test-http-methods.js (3 usages found)
  • test-http-outgoing-first-chunk-singlebyte-encoding.js (1 usage found)
  • test-http-parser.js (13 usages found)
  • test-http-write-head.js (1 usage found)
  • test-net-server-connections.js (1 usage found)
  • test-path-parse-format.js (1 usage found)
  • test-process-getgroups.js (1 usage found)
  • test-repl-tab-complete.js (11 usages found)
  • test-tls-interleave.js (1 usage found)

test\pummel

  • test-dtrace-jsstack.js (3 usages found)
  • test-regress-G H-814.js (1 usage found)
  • test-regress-GH-814_2.js (1 usage found)

and a special treat

  • test\parallel\test-buffer-indexof.js (292 usages found)

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussIssues opened for discussions and feedbacks.ltsIssues and PRs related to Long Term Support releases.testIssues and PRs related to the tests.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions