Skip to content

Commit d589076

Browse files
committed
remove the rest of enzyme
1 parent 77d699f commit d589076

File tree

11 files changed

+66
-573
lines changed

11 files changed

+66
-573
lines changed

packages/libraries/core/jest.setup.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/utils/test-tools/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Test-tools
22

3-
This is a dev environment only private package designed to aid in testing components via jest and enzyme
3+
This is a dev environment only private package designed to aid in testing components via jest

packages/utils/test-tools/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@fluentui-react-native/test-tools",
33
"version": "0.1.1",
4-
"description": "Tools and mocks for testing components using jest and enzyme",
4+
"description": "Tools and mocks for testing components using jest",
55
"main": "lib-commonjs/index.js",
66
"module": "src/index.ts",
77
"typings": "lib/index.d.ts",
@@ -12,7 +12,6 @@
1212
"clean": "fluentui-scripts clean",
1313
"depcheck": "fluentui-scripts depcheck",
1414
"lint": "fluentui-scripts eslint",
15-
"test": "fluentui-scripts jest",
1615
"update-snapshots": "fluentui-scripts jest -u",
1716
"prettier": "fluentui-scripts prettier",
1817
"prettier-fix": "fluentui-scripts prettier --fix true"
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import * as React from 'react';
2+
3+
import * as renderer from 'react-test-renderer';
4+
5+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6+
export function validateHookValueNotChanged<TValues extends NonNullable<any>[]>(
7+
testDescription: string,
8+
useHook: () => TValues,
9+
useHookAgain?: () => TValues,
10+
) {
11+
it(testDescription || 'returns the same value(s) each time', () => {
12+
let latestValues: TValues | undefined;
13+
let callCount = 0;
14+
15+
const TestComponent: React.FunctionComponent = () => {
16+
callCount++;
17+
// eslint-disable-next-line react-hooks/rules-of-hooks
18+
latestValues = callCount === 1 ? useHook() : (useHookAgain || useHook)();
19+
return <React.Fragment />;
20+
};
21+
22+
const wrapper = renderer.create(<TestComponent />);
23+
expect(callCount).toBe(1);
24+
const firstValues = latestValues;
25+
expect(firstValues).toBeDefined();
26+
latestValues = undefined;
27+
28+
wrapper.update(<TestComponent />);
29+
expect(callCount).toBe(2);
30+
expect(latestValues).toBeDefined();
31+
expect(latestValues.length).toEqual(firstValues!.length);
32+
33+
for (let i = 0; i < latestValues!.length; i++) {
34+
try {
35+
expect(latestValues![i]).toBe(firstValues![i]);
36+
} catch (err) {
37+
// Make a more informative error message
38+
const valueText = latestValues![i].toString();
39+
expect('').toBe(`Identity of value at index ${i} has changed. This might help identify it:\n${valueText}`);
40+
}
41+
}
42+
});
43+
}

packages/utils/test-tools/src/enzymeTests.test.tsx

Lines changed: 0 additions & 82 deletions
This file was deleted.

packages/utils/test-tools/src/enzymeTests.tsx

Lines changed: 0 additions & 138 deletions
This file was deleted.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
export { checkReRender, checkRenderConsistency, compareTrees, snapshotPropTree, validateHookValueNotChanged } from './enzymeTests';
2-
export type { JSXProducer, PropTreeFilter, PropTreeSnapshot } from './enzymeTests';
1+
export { validateHookValueNotChanged } from './baseTests';
32
export { mockTheme } from './mockTheme';

scripts/package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,13 @@
2828
"@react-native-community/cli-platform-ios": "^12.1.1",
2929
"@react-native/metro-babel-transformer": "^0.73.0",
3030
"@rnx-kit/jest-preset": "^0.1.14",
31-
"@types/enzyme": "^3.10.5",
3231
"@types/es6-collections": "^0.5.29",
3332
"@types/es6-promise": "0.0.32",
3433
"@types/jest": "^29.0.0",
3534
"@types/node": "^12.11.2",
3635
"@types/react-test-renderer": "16.9.0",
3736
"@uifabric/prettier-rules": "^7.0.3",
38-
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.5",
3937
"depcheck": "^1.0.0",
40-
"enzyme": "^3.11.0",
41-
"enzyme-to-json": "^3.5.0",
4238
"find-up": "^5.0.0",
4339
"fs-extra": "^7.0.1",
4440
"jest": "^29.2.1",

scripts/src/configs/configureJest.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@ export function configureJest(customConfig?: object): object {
2020
KeyCodes: path.resolve(__dirname, 'jest/jest-mock.js'),
2121
// Jest is picking up the hoisted version of lru-cache, which is
2222
// incompatible from the version required by semver
23-
'lru-cache': require.resolve('lru-cache', {paths:[require.resolve('semver')]}),
23+
'lru-cache': require.resolve('lru-cache', { paths: [require.resolve('semver')] }),
2424
},
2525
moduleFileExtensions,
2626
moduleDirectories: nodeModulesToRoot(),
2727

28-
snapshotSerializers: ['enzyme-to-json/serializer'],
29-
3028
// use babel-jest to transform files including typescript
3129
transform: {
3230
'^.+\\.(js|ts|tsx)?$': 'babel-jest',
@@ -49,7 +47,6 @@ export function configureReactNativeJest(platform?: PlatformValue, customConfig?
4947
return jestPreset(ensurePlatform(platform, 'ios'), {
5048
roots: ['<rootDir>/src'],
5149
verbose: false,
52-
setupFilesAfterEnv: [path.join(__dirname, 'jest', 'setupEnzyme.js')],
5350
...customConfig,
5451
});
5552
}

scripts/src/configs/jest/setupEnzyme.js

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)