Skip to content

Use native and tracked arrays in tests that are not about Ember arrays - #21690

Merged
NullVoxPopuli merged 1 commit into
emberjs:mainfrom
NullVoxPopuli-ai-agent:nvp/array-tests-native
Oct 11, 2026
Merged

NullVoxPopuli merged 1 commit into
emberjs:mainfrom
NullVoxPopuli-ai-agent:nvp/array-tests-native

Conversation

@NullVoxPopuli-ai-agent

Copy link
Copy Markdown
Contributor

Tests that are not about Ember arrays stop using A() from @ember/array. Only test files change.

Why this is a separate PR

#21687 deprecates A() (RFC 1114). In review of that PR, @ef4 said that a test must do one of two things:

  • If the test is about Ember arrays, it uses the public A(), expects the deprecation, and has a guard, so the test goes away with A().
  • If the test is about arrays in general, it uses a native array or trackedArray.

Most tests that call A() are in the second group. They use A() only for historical reasons. This PR moves that group, and it has no dependency on the deprecation, so it can merge first.

#21687 has this same change as its first commit. After this PR merges, that commit drops out of #21687, and #21687 shows only the deprecation.

Changes

A test uses a native array if it replaces the array, and trackedArray if it changes the array in place. The assertions are the same.

pushObject(x)       push(x)
popObject()         pop()
shiftObject()       shift()
clear()             splice(0)
removeAt(i)         splice(i, 1)
insertAt(i, x)      splice(i, 0, x)
setEach(key, v)     forEach((item) => set(item, key, v))
findBy('id', v)     find((item) => item.id === v)
  • Rendering tests: positional params, curly components, life cycle, link-to, let, if, unbound.
  • Application tests: route models and query param values.
  • ArrayProxy tests where the content does not need Ember array methods (isArray, isEmpty, content listeners).
  • each: an Ember array that goes through A() again is the same array, so the second call is gone.

Two tests change shape:

  • it considers empty arrays falsy used Ember arrays. It is now a native array test, and it considers empty Ember arrays falsy keeps the old body.
  • observable_test.js made an Ember array in beforeEach for a full module. Only should notify array observer when array changes needs it, so that test makes it.

Not in this PR

Tests about Ember arrays do not change: the array suites, the ArrayProxy suites, the array macro tests, the Ember array cases of each and of the conditionals, and the tests of [] and @each chains. #21687 adds the deprecation expectations and guards to those.

Test results

Local runs of the full suite on this branch:

default                         9286 pass, 18 skip, 0 fail
ALL_DEPRECATIONS_ENABLED=true   9286 pass, 18 skip, 0 fail

🤖 Generated with Claude Code

Many tests call `A()` from `@ember/array` only for historical reasons.
RFC 1114 deprecates `A()`, so each such test would need a deprecation
expectation and a removal guard, and its coverage would go away with
`A()`.

These tests now use a native array, or `trackedArray` when the test
changes the array in place. The assertions are the same.

- Rendering tests: positional params, curly components, life cycle,
  `link-to`, `let`, `if`, `unbound`.
- Application tests: route models and query param values.
- `ArrayProxy` tests where the content does not need Ember array
  methods.
- `it considers empty arrays falsy` has a native array version and an
  Ember array version.
- `observable_test.js` makes the Ember array in the one test that
  needs it.

Tests about Ember arrays do not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NullVoxPopuli
NullVoxPopuli merged commit 1dd02bd into emberjs:main Oct 11, 2026
68 checks passed
@NullVoxPopuli
NullVoxPopuli deleted the nvp/array-tests-native branch October 11, 2026 15:45
@github-actions github-actions Bot mentioned this pull request Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants