Skip to content

Commit

Permalink
chore: migrate monorepo to jest 28 (#26958)
Browse files Browse the repository at this point in the history
* chore: migrate monorepo to jest 28

* feat(test-utilities): move private test/ helpers from utilities package to make test pass with jest 28

* generate changefiles

* chore: bump/dedupe babel family of packages
  • Loading branch information
Hotell authored Feb 28, 2023
1 parent 569887e commit dd0f5b7
Show file tree
Hide file tree
Showing 39 changed files with 1,176 additions and 499 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "chore: bump jest types for template",
"packageName": "@fluentui/cra-template",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore: update tsconfig lib as jest now requires at least ES2015",
"packageName": "@fluentui/keyboard-key",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore: update tsconfig lib as jest now requires at least ES2015",
"packageName": "@fluentui/merge-styles",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: export omit function",
"packageName": "@fluentui/react-utilities",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore: update tsconfig lib as jest now requires at least ES2015",
"packageName": "@fluentui/set-version",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "feat: move private test/ helpers from utilities package to make test pass with jest 28",
"packageName": "@fluentui/test-utilities",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: remove private test/ helpers used within monorepo tests",
"packageName": "@fluentui/utilities",
"email": "[email protected]",
"dependentChangeType": "patch"
}
44 changes: 22 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,23 @@
"@actions/core": "1.9.1",
"@actions/github": "5.0.3",
"@azure/data-tables": "13.0.0",
"@babel/core": "7.18.9",
"@babel/generator": "7.18.9",
"@babel/parser": "7.18.9",
"@babel/core": "7.21.0",
"@babel/generator": "7.21.1",
"@babel/parser": "7.21.1",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/plugin-proposal-decorators": "7.18.9",
"@babel/plugin-proposal-decorators": "7.21.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6",
"@babel/plugin-proposal-optional-chaining": "7.18.9",
"@babel/plugin-proposal-optional-chaining": "7.21.0",
"@babel/plugin-syntax-dynamic-import": "7.8.3",
"@babel/plugin-syntax-object-rest-spread": "7.8.3",
"@babel/plugin-transform-runtime": "7.18.9",
"@babel/preset-env": "7.18.9",
"@babel/plugin-transform-runtime": "7.21.0",
"@babel/preset-env": "7.20.2",
"@babel/preset-react": "7.18.6",
"@babel/preset-typescript": "7.18.6",
"@babel/register": "7.18.9",
"@babel/standalone": "7.18.9",
"@babel/traverse": "7.18.9",
"@babel/types": "7.20.7",
"@babel/register": "7.21.0",
"@babel/standalone": "7.21.1",
"@babel/traverse": "7.21.2",
"@babel/types": "7.21.2",
"@cactuslab/usepubsub": "^1.0.2",
"@ctrl/tinycolor": "3.3.4",
"@cypress/react": "5.12.4",
Expand All @@ -94,7 +94,7 @@
"@griffel/react": "^1.5.2",
"@griffel/webpack-extraction-plugin": "0.3.3",
"@griffel/webpack-loader": "2.1.8",
"@jest/reporters": "27.5.1",
"@jest/reporters": "28.1.3",
"@mdx-js/loader": "1.6.22",
"@microsoft/api-extractor": "7.18.1",
"@microsoft/eslint-plugin-sdl": "0.1.9",
Expand Down Expand Up @@ -127,7 +127,7 @@
"@swc/core": "1.3.30",
"@swc/helpers": "0.4.14",
"@testing-library/dom": "8.11.3",
"@testing-library/jest-dom": "5.16.1",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "12.1.2",
"@testing-library/react-hooks": "7.0.2",
"@testing-library/user-event": "13.5.0",
Expand All @@ -153,7 +153,7 @@
"@types/gulp-remember": "0.0.31",
"@types/gulp-sourcemaps": "0.0.35",
"@types/gulp-util": "3.0.36",
"@types/jest": "27.5.2",
"@types/jest": "28.1.8",
"@types/jest-axe": "3.5.5",
"@types/jju": "1.4.1",
"@types/json-schema": "^7.0.8",
Expand Down Expand Up @@ -190,7 +190,7 @@
"@wojtekmaj/enzyme-adapter-react-17": "0.6.7",
"ajv": "8.4.0",
"autoprefixer": "10.2.1",
"babel-jest": "27.5.1",
"babel-jest": "28.1.3",
"babel-loader": "8.2.2",
"babel-plugin-annotate-pure-calls": "0.4.0",
"babel-plugin-annotate-pure-imports": "1.0.0-1",
Expand Down Expand Up @@ -254,13 +254,13 @@
"html-webpack-plugin": "5.1.0",
"ignore-not-found-export-webpack-plugin": "1.0.2",
"imports-loader": "1.2.0",
"jest": "27.5.1",
"jest": "28.1.3",
"jest-axe": "6.0.1",
"jest-cli": "27.5.1",
"jest-environment-jsdom": "27.5.1",
"jest-environment-node-single-context": "27.3.0",
"jest-snapshot": "27.5.1",
"jest-watch-typeahead": "0.6.5",
"jest-cli": "28.1.3",
"jest-environment-jsdom": "28.1.3",
"jest-environment-node-single-context": "28.1.0",
"jest-snapshot": "28.1.3",
"jest-watch-typeahead": "1.1.0",
"jju": "1.4.0",
"json-schema": "0.4.0",
"json-stable-stringify-without-jsonify": "1.0.1",
Expand Down Expand Up @@ -331,7 +331,7 @@
"terser-webpack-plugin": "5.3.1",
"through2": "4.0.2",
"tmp": "0.2.1",
"ts-jest": "27.1.5",
"ts-jest": "28.0.8",
"ts-loader": "9.3.1",
"ts-node": "10.9.1",
"tsconfig-paths": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/bundle-size/src/utils/prepareFixture.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default { foo: 'bar' }
`);

await expect(prepareFixture(fixturePath)).rejects.toMatchInlineSnapshot(
`[Error: unknown: Validation failed for a schema in a component: data must have required property 'name']`,
`[Error: unknown file: Validation failed for a schema in a component: data must have required property 'name']`,
);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/cra-template/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@types/node": "^14.0.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@types/jest": "^27.5.2",
"@types/jest": "^28.1.8",
"react": "^17.0.0",
"react-dom": "^17.0.0",
"typescript": "^4.1.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/keyboard-key/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"outDir": "dist",
"target": "es5",
"module": "commonjs",
"lib": ["ES5", "ES2015.Collection", "DOM"],
"jsx": "react",
"declaration": true,
"sourceMap": true,
Expand All @@ -15,7 +16,6 @@
"noImplicitAny": true,
"moduleResolution": "node",
"preserveConstEnums": true,
"lib": ["es5", "dom"],
"types": ["jest"],
"isolatedModules": true
},
Expand Down
2 changes: 1 addition & 1 deletion packages/merge-styles/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"target": "es5",
"outDir": "lib",
"module": "commonjs",
"lib": ["es5", "dom"],
"lib": ["ES5", "ES2015.Collection", "dom"],
"jsx": "react",
"declaration": true,
"sourceMap": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { isConformant } from '../../testing/isConformant';
import { omit } from '@fluentui/react-utilities/src/utils/omit';
import { omit } from '@fluentui/react-utilities';
import { Persona } from './Persona';
import { personaClassNames } from './usePersonaStyles';
import { render, screen } from '@testing-library/react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ export function mergeCallbacks<Args extends unknown[]>(callback1: ((...args: Arg
// @public (undocumented)
export type NativeTouchOrMouseEvent = MouseEvent | TouchEvent;

// @public
export function omit<TObj extends Record<string, any>, Exclusions extends (keyof TObj)[]>(obj: TObj, exclusions: Exclusions): Omit<TObj, Exclusions[number]>;

// @public (undocumented)
export type ReactTouchOrMouseEvent = React_2.MouseEvent | React_2.TouchEvent;

Expand Down
1 change: 1 addition & 0 deletions packages/react-components/react-utilities/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export {
mergeCallbacks,
isHTMLElement,
isInteractiveHTMLElement,
omit,
} from './utils/index';

export { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Fabric/Fabric.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable deprecation/deprecation */
import * as React from 'react';
import { create } from '@fluentui/utilities/lib/test';
import { create } from '@fluentui/test-utilities';
//import { Customizer } from '@fluentui/utilities';
import { Fabric } from './Fabric';
//import { Checkbox } from '@fluentui/react/lib/Checkbox';
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Image/Image.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { mount } from 'enzyme';
import * as React from 'react';
import { create } from '@fluentui/utilities/lib/test';
import { create } from '@fluentui/test-utilities';
import { Image } from './Image';
import { ImageBase } from './Image.base';
import { ImageFit, ImageCoverStyle } from './Image.types';
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Link/Link.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mount } from 'enzyme';
import * as React from 'react';
import * as ReactDOM from 'react-dom/server';
import { create } from '@fluentui/utilities/lib/test';
import { create } from '@fluentui/test-utilities';
import { Customizer } from '@fluentui/utilities';
import { createTheme } from '@fluentui/style-utilities';
import { isConformant } from '../../common/isConformant';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { shallow } from 'enzyme';
import { ReactWrapper, mount } from 'enzyme';
import * as React from 'react';
import { create } from '@fluentui/utilities/lib/test';
import { create } from '@fluentui/test-utilities';
import * as ReactTestUtils from 'react-dom/test-utils';
import { CommandBarButton } from '../../Button';
import { KeytipLayer, KeytipLayerBase } from '../../KeytipLayer';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { create } from '@fluentui/utilities/lib/test';
import { create } from '@fluentui/test-utilities';
import { setRTL, setWarningCallback } from '@fluentui/utilities';
import { Persona } from './Persona';
import { mount } from 'enzyme';
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Persona/Persona.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { create } from '@fluentui/utilities/lib/test';
import { create } from '@fluentui/test-utilities';
import { TestImages } from '@fluentui/example-data';
import { Icon } from '../../Icon';
import { setRTL } from '../../Utilities';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { create } from '@fluentui/utilities/lib/test';
import { create } from '@fluentui/test-utilities';
import { setWarningCallback, setRTL } from '../../../Utilities';
import { PersonaCoin } from './PersonaCoin';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { create } from '@fluentui/utilities/lib/test';
import { create } from '@fluentui/test-utilities';
import { setRTL } from '../../../Utilities';
import { PersonaCoin } from './PersonaCoin';
import { wrapPersona } from '../test-utils';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { create } from '@fluentui/utilities/lib/test';
import { create } from '@fluentui/test-utilities';
import { setRTL } from '../../../Utilities';
import * as PersonaTypes from '../Persona.types';
import { PersonaPresence } from './PersonaPresence';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { create } from '@fluentui/utilities/lib/test';
import { create } from '@fluentui/test-utilities';
import { setWarningCallback, resetIds } from '@fluentui/utilities';

import { Pivot, PivotItem } from './index';
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/SearchBox/SearchBox.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { create } from '@fluentui/utilities/lib/test';
import { create } from '@fluentui/test-utilities';
import { mount, ReactWrapper } from 'enzyme';
import { SearchBox } from './SearchBox';
import { KeyCodes, resetIds } from '../../Utilities';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import * as ReactTestUtils from 'react-dom/test-utils';
import { create } from '@fluentui/utilities/lib/test';
import { create } from '@fluentui/test-utilities';
import { ReactWrapper, mount } from 'enzyme';

import { SpinButton } from './SpinButton';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { create } from '@fluentui/utilities/lib/test';
import { create } from '@fluentui/test-utilities';
import { mount } from 'enzyme';
import { SwatchColorPicker } from './SwatchColorPicker';
import { resetIds } from '@fluentui/utilities';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { TimePicker } from './TimePicker';
// import { ITimeRange } from './TimePicker.types';
// import { create } from '@fluentui/utilities/lib/test';
// import { create } from '@fluentui/test-utilities';
import { mount } from 'enzyme';
import type { IComboBox } from '../ComboBox/ComboBox.types';
import { KeyCodes } from '../../Utilities';
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Toggle/Toggle.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { mount } from 'enzyme';
import { create } from '@fluentui/utilities/lib/test';
import { create } from '@fluentui/test-utilities';
import { resetIds } from '@fluentui/utilities';
import { Toggle } from './Toggle';
import { isConformant } from '../../common/isConformant';
Expand Down
2 changes: 1 addition & 1 deletion packages/set-version/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"target": "es5",
"outDir": "lib",
"module": "commonjs",
"lib": ["es5", "dom"],
"lib": ["ES5", "ES2015.Collection", "dom"],
"declaration": true,
"sourceMap": true,
"importHelpers": true,
Expand Down
6 changes: 6 additions & 0 deletions packages/test-utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,11 @@
"enzyme": "^3.0.0",
"react": ">=16.8.0 <19.0.0",
"react-test-renderer": ">=16.3.0 <18.0.0"
},
"exports": {
".": {
"types": "./lib-commonjs/index.d.ts",
"require": "./lib-commonjs/index.js"
}
}
}
1 change: 1 addition & 0 deletions packages/test-utilities/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export { createTestContainer } from './createTestContainer';
export { getCSSRules } from './getCSSRules';
export { safeCreate } from './safeCreate';
export { safeMount } from './safeMount';
export { create } from './reactTestRenderer';
2 changes: 0 additions & 2 deletions packages/utilities/src/test/index.ts

This file was deleted.

22 changes: 0 additions & 22 deletions packages/utilities/src/test/injectWrapperMethod.ts

This file was deleted.

Loading

0 comments on commit dd0f5b7

Please sign in to comment.