Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Remove jest extended #2839

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"intl-pluralrules": "^0.2.1",
"jest": "^29.4.2",
"jest-environment-jsdom": "^29.4.2",
"jest-extended": "^3.2.3",
"jest-runner-tsd": "^4.0.0",
"jest-watch-typeahead": "^2.2.2",
"npm-run-all": "^4.1.5",
Expand Down
40 changes: 32 additions & 8 deletions packages/graphql-fixtures/src/tests/fill.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ describe('createFillers()', () => {
}
`);

expect(fillOperation(document)).toBeOneOf([
const possibleResults = [
{
named: {
__typename: 'Person',
Expand All @@ -1203,7 +1203,13 @@ describe('createFillers()', () => {
name: expect.any(String),
},
},
]);
];

// The result of fillOperation is random based on a seed.
// Its value should be one of items in the possibleResults array
expect(possibleResults).toStrictEqual(
expect.arrayContaining([fillOperation(document)]),
);
});

it('always picks the same implementing type', () => {
Expand Down Expand Up @@ -1387,7 +1393,7 @@ describe('createFillers()', () => {
}
`);

expect(fillFragment(fragment)).toBeOneOf([
const possibleResults = [
{
named: {
__typename: 'Person',
Expand All @@ -1408,7 +1414,13 @@ describe('createFillers()', () => {
name: expect.any(String),
},
},
]);
];

// The result of fillFragment is random based on a seed.
// Its value should be one of items in the possibleResults array
expect(possibleResults).toStrictEqual(
expect.arrayContaining([fillFragment(fragment)]),
);
});

it('picks an implementing type based on a static typename provided', () => {
Expand Down Expand Up @@ -1607,7 +1619,7 @@ describe('createFillers()', () => {
}
`);

expect(fillOperation(document)).toBeOneOf([
const possibleResults = [
{
named: {
__typename: 'Person',
Expand All @@ -1625,7 +1637,13 @@ describe('createFillers()', () => {
__typename: 'Dog',
},
},
]);
];

// The result of fillOperation is random based on a seed.
// Its value should be one of items in the possibleResults array
expect(possibleResults).toStrictEqual(
expect.arrayContaining([fillOperation(document)]),
);
});

it('picks a member type based on a static typename provided', () => {
Expand Down Expand Up @@ -1754,7 +1772,7 @@ describe('createFillers()', () => {
}
`);

expect(fillFragment(fragment)).toBeOneOf([
const possibleResults = [
{
named: {
__typename: 'Person',
Expand All @@ -1772,7 +1790,13 @@ describe('createFillers()', () => {
__typename: 'Dog',
},
},
]);
];

// The result of fillFragment is random based on a seed.
// Its value should be one of items in the possibleResults array
expect(possibleResults).toStrictEqual(
expect.arrayContaining([fillFragment(fragment)]),
);
});

it('picks a member type based on a static typename provided', () => {
Expand Down
3 changes: 0 additions & 3 deletions packages/react-i18n/src/tests/e2e/server.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
* @jest-environment node
*/

import '../matchers';

import React from 'react';
import {renderToStaticMarkup} from 'react-dom/server';
import {extract, Effect} from '@shopify/react-effect/server';
Expand Down Expand Up @@ -105,7 +103,6 @@ describe('server', () => {
const translations = manager.extract();

const extractedTranslations = Object.values(translations);
expect(Object.keys(translations)).toBeArrayOfUniqueItems();
expect(extractedTranslations).toContain(frCATranslations);
expect(extractedTranslations).toContain(frTranslations);
});
Expand Down
2 changes: 0 additions & 2 deletions packages/react-i18n/src/tests/i18n.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {clock} from '@shopify/jest-dom-mocks';

import './matchers';

import {I18n} from '../i18n';
import {LanguageDirection} from '../types';
import {DateStyle, Weekday} from '../constants';
Expand Down
4 changes: 0 additions & 4 deletions packages/react-i18n/src/tests/manager.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import './matchers';

import {animationFrame} from '@shopify/jest-dom-mocks';

import {I18nManager} from '../manager';
Expand Down Expand Up @@ -447,8 +445,6 @@ describe('I18nManager', () => {
await manager.resolve();

const translationsByID = manager.extract();
expect(Object.keys(translationsByID)).toBeArrayOfUniqueItems();

const translations = Object.values(translationsByID);
expect(translations).toContain(enUS);
expect(translations).toContain(en);
Expand Down
27 changes: 0 additions & 27 deletions packages/react-i18n/src/tests/matchers.ts

This file was deleted.

22 changes: 16 additions & 6 deletions tests/consistent-package-json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,23 @@ packages.forEach(
(key) => key !== GLOB_PATH,
);

exportsKeys.forEach((key) => {
expect(packageJSON.exports[key]).toBeObject();
const possibleResults = [
['types', 'default'],
['types', 'esnext', 'import', 'require'],
];

expect(Object.keys(packageJSON.exports[key])).toBeOneOf([
['types', 'default'],
['types', 'esnext', 'import', 'require'],
]);
exportsKeys.forEach((key) => {
expect(packageJSON.exports[key]).toMatchObject({
types: expect.anything(),
});

// The result of exports key could be one of two shapes
// Its value should be one of items in the possibleResults array
// We don't want to test against "an object containing keys", as the
// order of the keys is important
expect(possibleResults).toStrictEqual(
expect.arrayContaining([Object.keys(packageJSON.exports[key])]),
);

// types/typesVersions is referenced when using `moduleResolution: node`
// types in the exports field is referenced when using `moduleResolution: node16`
Expand Down
27 changes: 0 additions & 27 deletions tests/matchers/index.ts

This file was deleted.

5 changes: 0 additions & 5 deletions tests/setup/tests.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import {toBeObject, toBeOneOf} from 'jest-extended';

import '../matchers';
import '../../packages/react-testing/src/matchers';
import '../../packages/graphql-testing/src/matchers';

import {destroyAll} from '../../packages/react-testing/src/destroy';

expect.extend({toBeObject, toBeOneOf});

// eslint-disable-next-line jest/require-top-level-describe
afterEach(async () => {
await destroyAll();
Expand Down
2 changes: 1 addition & 1 deletion tests/utilities.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {resolve, sep} from 'path';

// For packages that have been emptied pending removal
export const EXCLUDED_PACKAGES = [];
export const EXCLUDED_PACKAGES: string[] = [];

const rootDirectory = `${resolve(__dirname, '..')}${sep}`;
const regex = new RegExp(rootDirectory, 'g');
Expand Down
12 changes: 2 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9837,7 +9837,7 @@ jest-diff@^26.6.2:
jest-get-type "^26.3.0"
pretty-format "^26.6.2"

jest-diff@^29.0.0, jest-diff@^29.4.2:
jest-diff@^29.4.2:
version "29.4.2"
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-29.4.2.tgz#b88502d5dc02d97f6512d73c37da8b36f49b4871"
integrity sha512-EK8DSajVtnjx9sa1BkjZq3mqChm2Cd8rIzdXkQMA8e0wuXq53ypz6s5o5V8HRZkoEt2ywJ3eeNWFKWeYr8HK4g==
Expand Down Expand Up @@ -9891,20 +9891,12 @@ jest-environment-node@^29.4.2:
jest-mock "^29.4.2"
jest-util "^29.4.2"

jest-extended@^3.2.3:
version "3.2.3"
resolved "https://registry.yarnpkg.com/jest-extended/-/jest-extended-3.2.3.tgz#286c19b4622e2ab828e1bb28d3b2d4a1ed64f8b9"
integrity sha512-YcdjfFv3+N2AiWq4aG6gT/r1mfLtDKnbXs0hKXNlL/hf37TKQJTlh2zNwuMUYnvwKRRMtO/X9CfZU1EmOgUREA==
dependencies:
jest-diff "^29.0.0"
jest-get-type "^29.0.0"

jest-get-type@^26.3.0:
version "26.3.0"
resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-26.3.0.tgz#e97dc3c3f53c2b406ca7afaed4493b1d099199e0"
integrity sha512-TpfaviN1R2pQWkIihlfEanwOXK0zcxrKEE4MlU6Tn7keoXdN6/3gK/xl0yEh8DOunn5pOVGKf8hB4R9gVh04ig==

jest-get-type@^29.0.0, jest-get-type@^29.4.2:
jest-get-type@^29.4.2:
version "29.4.2"
resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-29.4.2.tgz#7cb63f154bca8d8f57364d01614477d466fa43fe"
integrity sha512-vERN30V5i2N6lqlFu4ljdTqQAgrkTFMC9xaIIfOPYBw04pufjXRty5RuXBiB1d72tGbURa/UgoiHB90ruOSivg==
Expand Down
Loading