Repository: angular/angular-cli
File: packages/schematics/angular/refactor/jasmine-vitest/transformers/jasmine-matcher_spec.ts (TypeScript)

Code before:
        expected: `expect([]).toHaveLength(0);`,
      },
      {
        description: 'should transform toEqual(jasmine.is()) to toBe()',
        input: `expect(value).toEqual(jasmine.is(otherValue));`,
        expected: `expect(value).toBe(otherValue);`,
      },
    ];

    testCases.forEach(({ description, input, expected }) => {
      it(description, async () => {
        await expectTransformation(input, expected);
      });
    });
  });

  describe('transformArrayWithExactContents', () => {
    const testCases = [
      {
        description: 'should transform toEqual(jasmine.arrayWithExactContents()) into two calls',
        input: `expect(myArray).toEqual(jasmine.arrayWithExactContents(['a', 'b']));`,
        expected: `
          expect(myArray).toHaveLength(2);
          expect(myArray).toEqual(expect.arrayContaining(['a', 'b']));
        `,
      },
      {
        description:
          'should transform toEqual(jasmine.arrayWithExactContents()) with asymmetric matchers',
        input: `expect(myArray).toEqual(jasmine.arrayWithExactContents([jasmine.any(Number), 'a']));`,
        expected: `
          expect(myArray).toHaveLength(2);
          expect(myArray).toEqual(expect.arrayContaining([expect.any(Number), 'a']));
        `,
      },
      {
        description:
          'should add a TODO for toEqual(jasmine.arrayWithExactContents()) with a variable',
        input: `expect(myArray).toEqual(jasmine.arrayWithExactContents(someOtherArray));`,
        expected: `
          // TODO: vitest-migration: Cannot transform jasmine.arrayWithExactContents with a dynamic variable. Please migrate this manually.
          expect(myArray).toEqual(jasmine.arrayWithExactContents(someOtherArray));
        `,
      },
    ];

    testCases.forEach(({ description, input, expected }) => {
      it(description, async () => {
        await expectTransformation(input, expected);
      });
    });

Review comment (suggestion):
This is how you do the same in Jest/Vitest:

```suggestion
          expect(myArray).toEqual(['a', 'b']);
```

Code after:
        expected: `expect([]).toHaveLength(0);`,
      },
      {
        description: 'should transform toEqual(jasmine.is()) to toBe()',
        input: `expect(value).toEqual(jasmine.is(otherValue));`,
        expected: `expect(value).toBe(otherValue);`,
      },
    ];

    testCases.forEach(({ description, input, expected }) => {
      it(description, async () => {
        await expectTransformation(input, expected);
      });
    });
  });

  describe('transformArrayWithExactContents', () => {
    const testCases = [
      {
        description: 'should transform toEqual(jasmine.arrayWithExactContents()) into two calls',
        input: `expect(myArray).toEqual(jasmine.arrayWithExactContents(['a', 'b']));`,
        /* eslint-disable max-len */
        expected: `
          // TODO: vitest-migration: Verify this matches strict array content (multiset equality). Vitest's arrayContaining is a subset check.
          expect(myArray).toHaveLength(2);
          expect(myArray).toEqual(expect.arrayContaining(['a', 'b']));
        `,
        /* eslint-enable max-len */
      },
      {
        description:
          'should transform toEqual(jasmine.arrayWithExactContents()) with asymmetric matchers',
        input: `expect(myArray).toEqual(jasmine.arrayWithExactContents([jasmine.any(Number), 'a']));`,
        /* eslint-disable max-len */
        expected: `
          // TODO: vitest-migration: Verify this matches strict array content (multiset equality). Vitest's arrayContaining is a subset check.
          expect(myArray).toHaveLength(2);
          expect(myArray).toEqual(expect.arrayContaining([expect.any(Number), 'a']));
        `,
        /* eslint-enable max-len */
      },
      {
        description:
          'should add a TODO for toEqual(jasmine.arrayWithExactContents()) with a variable',
        input: `expect(myArray).toEqual(jasmine.arrayWithExactContents(someOtherArray));`,
        expected: `
          // TODO: vitest-migration: Cannot transform jasmine.arrayWithExactContents with a dynamic variable. Please migrate this manually.
          expect(myArray).toEqual(jasmine.arrayWithExactContents(someOtherArray));
        `,
      },
    ];