Skip to content
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
2 changes: 1 addition & 1 deletion apps/react-18-tests-v8/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const config = createConfig({
if (config.globals) {
// override ts-jest config, otherwise it gets merged
config.globals['ts-jest'] = {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: { warnOnly: true /* , exclude: ['packages/**'] */ },
};
}
Expand Down
2 changes: 1 addition & 1 deletion apps/react-18-tests-v9/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: { warnOnly: true, exclude: ['packages/**'] },
},
},
Expand Down
2 changes: 1 addition & 1 deletion apps/ssr-tests-v9/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion apps/stress-test/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion apps/vr-tests-react-components/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.json',
tsconfig: '<rootDir>/tsconfig.json',
diagnostics: false,
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "chore: bump template jest types to v27",
"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: migrate to jest 27",
"packageName": "@fluentui/react",
"email": "[email protected]",
"dependentChangeType": "none"
}
3 changes: 2 additions & 1 deletion jest.preset.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check

const path = require('path');
const { pathsToModuleNameMapper } = require('ts-jest/utils');
const { pathsToModuleNameMapper } = require('ts-jest');

const tsConfig = require('./tsconfig.base.json');

Expand All @@ -19,6 +19,7 @@ const baseConfig = {
testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
testPathIgnorePatterns: ['/node_modules/', '/lib/', '/lib-commonjs/', '/dist/'],
testEnvironment: 'jsdom',
moduleNameMapper: { ...tsPathAliases },
cacheDirectory: '<rootDir>/node_modules/.cache/jest',
clearMocks: true,
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"@griffel/react": "^1.5.2",
"@griffel/webpack-extraction-plugin": "0.3.3",
"@griffel/webpack-loader": "2.1.8",
"@jest/reporters": "26.6.2",
"@jest/reporters": "27.5.1",
"@mdx-js/loader": "1.6.22",
"@microsoft/api-extractor": "7.18.1",
"@microsoft/eslint-plugin-sdl": "0.1.9",
Expand Down Expand Up @@ -153,7 +153,7 @@
"@types/gulp-remember": "0.0.31",
"@types/gulp-sourcemaps": "0.0.35",
"@types/gulp-util": "3.0.36",
"@types/jest": "26.0.24",
"@types/jest": "27.5.2",
"@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": "26.6.3",
"babel-jest": "27.5.1",
"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,12 +254,12 @@
"html-webpack-plugin": "5.1.0",
"ignore-not-found-export-webpack-plugin": "1.0.2",
"imports-loader": "1.2.0",
"jest": "26.6.3",
"jest": "27.5.1",
"jest-axe": "6.0.1",
"jest-cli": "26.6.3",
"jest-environment-jsdom": "26.6.2",
"jest-environment-node-single-context": "26.2.0",
"jest-snapshot": "26.6.2",
"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",
"jju": "1.4.0",
"json-schema": "0.4.0",
Expand Down Expand Up @@ -331,7 +331,7 @@
"terser-webpack-plugin": "5.3.1",
"through2": "4.0.2",
"tmp": "0.2.1",
"ts-jest": "26.5.6",
"ts-jest": "27.1.5",
"ts-loader": "9.3.1",
"ts-node": "10.9.1",
"tsconfig-paths": "4.1.0",
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": "^26.0.15",
"@types/jest": "^27.5.2",
"react": "^17.0.0",
"react-dom": "^17.0.0",
"typescript": "^4.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,8 @@ import { FocusZone, AutoFocusZone } from '@fluentui/react-bindings';
import * as React from 'react';
import * as ReactTestUtils from 'react-dom/test-utils';

// rAF does not exist in node - let's mock it
window.requestAnimationFrame = (callback: FrameRequestCallback) => {
const r = window.setTimeout(callback, 0);
jest.runAllTimers();
return r;
};

const animationFrame = () => new Promise(resolve => window.requestAnimationFrame(resolve));
jest.useFakeTimers();
const originalRAF = window.requestAnimationFrame;

describe('AutoFocusZone', () => {
let lastFocusedElement: HTMLElement | undefined;
Expand Down Expand Up @@ -47,8 +40,17 @@ describe('AutoFocusZone', () => {
};

beforeEach(() => {
jest.useFakeTimers();
Object.defineProperty(window, 'requestAnimationFrame', {
writable: true,
value: (callback: FrameRequestCallback) => callback(0),
});
lastFocusedElement = undefined;
});
afterEach(() => {
jest.useRealTimers();
window.requestAnimationFrame = originalRAF;
});

describe('Focusing the ATZ', () => {
function setupTest(firstFocusableSelector?: string) {
Expand Down Expand Up @@ -96,6 +98,7 @@ describe('AutoFocusZone', () => {
// @ts-ignore
autoFocusZone.componentDidMount();
await animationFrame();

expect(lastFocusedElement).toBe(buttonF);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,7 @@ import * as ReactTestUtils from 'react-dom/test-utils';
import { createTestContainer } from './test-utils';
import * as FocusUtilities from '../../src/FocusZone/focusUtilities';

// rAF does not exist in node - let's mock it
window.requestAnimationFrame = (callback: FrameRequestCallback) => {
const r = window.setTimeout(callback, 0);
ReactTestUtils.act(() => {
jest.runAllTimers();
});
return r;
};

// ReactTestUtils.act(() => {
jest.useFakeTimers();
// });
const originalRAF = window.requestAnimationFrame;

class FocusTrapZoneTestComponent extends React.Component<
{},
Expand Down Expand Up @@ -123,11 +112,18 @@ describe('FocusTrapZone', () => {
}

beforeEach(() => {
jest.useFakeTimers();
Object.defineProperty(window, 'requestAnimationFrame', {
writable: true,
value: (callback: FrameRequestCallback) => callback(0),
});
lastFocusedElement = undefined;
});

afterAll(() => {
window.addEventListener = addEventListener;
window.requestAnimationFrame = originalRAF;
jest.useRealTimers();
});

describe('Tab and shift-tab wrap at extreme ends of the FTZ', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/global-context/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/keyboard-keys/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/react-accordion/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/react-alert/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/react-aria/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/react-avatar/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/react-badge/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/react-button/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/react-card/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/react-checkbox/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/react-combobox/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
Expand Down
Loading