Skip to content

Commit 860bb82

Browse files
authored
chore: implement test in memory execution based on TS aliases (#17161)
* chore(react-menu): implement in memory test execution * fix(react-conformance): remove esModuleInterop so the package is compliant with other packages * fix(utilities): make pkg compile in strict mode * chore(make-styles): propagate deps to root and remove path overrides so the package can be properly consumed by ts path aliases converged packages * chore(react-menu): add global types from dependant packages until we properly define globals type resolution for all * chore: remove packages from path aliases that have been removed from convergence * Change files
1 parent 4adad38 commit 860bb82

28 files changed

+147
-63
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ coverage
6565
dist
6666
dist-storybook
6767
screenshots
68+
.cache
6869

6970
*.tar.gz
7071

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "chore(make-styles): propagate deps to root and remove path overrides so the package can be properly consumed by ts path aliases converged packages",
4+
"packageName": "@fluentui/make-styles",
5+
"email": "martinhochel@microsoft.com",
6+
"dependentChangeType": "none"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "fix(react-conformance): remove esModuleInterop so the package is compliant with other packages",
4+
"packageName": "@fluentui/react-conformance",
5+
"email": "martinhochel@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "chore(react-menu): implement in memory test exection",
4+
"packageName": "@fluentui/react-menu",
5+
"email": "martinhochel@microsoft.com",
6+
"dependentChangeType": "none"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "fix(utilities): make pkg compile in strict mode",
4+
"packageName": "@fluentui/utilities",
5+
"email": "martinhochel@microsoft.com",
6+
"dependentChangeType": "none"
7+
}

jest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
projects: ['<rootDir>/packages/react-menu'],
3+
};

jest.preset.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// @ts-check
2+
3+
const path = require('path');
4+
const { pathsToModuleNameMapper } = require('ts-jest/utils');
5+
6+
const tsConfig = require('./tsconfig.base.json');
7+
8+
const tsPathAliases = pathsToModuleNameMapper(tsConfig.compilerOptions.paths, {
9+
prefix: `<rootDir>/${path.relative(process.cwd(), __dirname)}/`,
10+
});
11+
12+
/**
13+
* @type {jest.InitialOptions}
14+
*/
15+
const baseConfig = {
16+
transform: {
17+
'^.+\\.ts$': 'ts-jest',
18+
},
19+
testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
20+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
21+
testPathIgnorePatterns: ['/node_modules/', '/lib/', '/lib-commonjs/', '/dist/'],
22+
moduleNameMapper: { ...tsPathAliases },
23+
cacheDirectory: '<rootDir>/.cache/jest',
24+
clearMocks: true,
25+
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
26+
};
27+
28+
module.exports = { ...baseConfig };

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
"postcss-loader": "4.1.0",
110110
"postcss-modules": "2.0.0",
111111
"ts-loader": "8.0.14",
112-
"ts-jest": "24.0.1",
112+
"ts-jest": "24.3.0",
113113
"typescript": "3.7.2",
114114
"webpack-dev-server": "4.0.0-beta.0",
115115
"webpack-cli": "4.3.1",
@@ -124,6 +124,10 @@
124124
"packages/fluentui/*"
125125
],
126126
"nohoist": [
127+
"@fluentui/make-styles/stylis",
128+
"@fluentui/make-styles/@types/stylis",
129+
"@fluentui/react-bindings/stylis",
130+
"@fluentui/react-northstar-fela-renderer/stylis",
127131
"packages/web-components/webpack",
128132
"packages/web-components/@storybook/**",
129133
"packages/web-components/typescript",

packages/make-styles/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@fluentui/eslint-plugin": "^1.0.1",
2929
"@fluentui/scripts": "^1.0.0",
3030
"@fluentui/test-utilities": "^8.0.1",
31-
"@types/stylis": "^4.0.0"
31+
"@types/stylis": "4.0.0"
3232
},
3333
"dependencies": {
3434
"@emotion/hash": "^0.8.0",

packages/make-styles/tsconfig.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"compilerOptions": {
3-
"baseUrl": ".",
43
"outDir": "dist",
54
"target": "es5",
65
"module": "commonjs",
@@ -15,9 +14,6 @@
1514
"moduleResolution": "node",
1615
"preserveConstEnums": true,
1716
"lib": ["es5", "dom"],
18-
"paths": {
19-
"stylis": ["../../node_modules/@types/stylis"]
20-
},
2117
"typeRoots": ["../../node_modules/@types", "../../typings"],
2218
"types": ["custom-global", "jest", "inline-style-expand-shorthand"]
2319
},

0 commit comments

Comments
 (0)