@nx/jest 0.0.0-pr-22179-271588f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +68 -0
- package/executors.json +10 -0
- package/generators.json +19 -0
- package/index.d.ts +8 -0
- package/index.js +19 -0
- package/migrations.json +105 -0
- package/package.json +57 -0
- package/plugin.d.ts +1 -0
- package/plugin.js +6 -0
- package/plugins/resolver.d.ts +1 -0
- package/plugins/resolver.js +58 -0
- package/preset/index.d.ts +2 -0
- package/preset/index.js +4 -0
- package/preset/jest-preset.d.ts +2 -0
- package/preset/jest-preset.js +33 -0
- package/src/executors/jest/jest.impl.d.ts +10 -0
- package/src/executors/jest/jest.impl.js +179 -0
- package/src/executors/jest/schema.d.ts +44 -0
- package/src/executors/jest/schema.json +226 -0
- package/src/executors/jest/summary.d.ts +7 -0
- package/src/executors/jest/summary.js +154 -0
- package/src/generators/configuration/configuration.d.ts +5 -0
- package/src/generators/configuration/configuration.js +90 -0
- package/src/generators/configuration/files/jest.config.ts__tmpl__ +16 -0
- package/src/generators/configuration/files/src/test-setup.ts__tmpl__ +0 -0
- package/src/generators/configuration/files/tsconfig.spec.json__tmpl__ +21 -0
- package/src/generators/configuration/files-angular/jest.config.ts__tmpl__ +27 -0
- package/src/generators/configuration/files-angular/src/test-setup.ts__tmpl__ +1 -0
- package/src/generators/configuration/files-angular/tsconfig.spec.json__tmpl__ +22 -0
- package/src/generators/configuration/lib/check-for-test-target.d.ts +3 -0
- package/src/generators/configuration/lib/check-for-test-target.js +11 -0
- package/src/generators/configuration/lib/create-files.d.ts +3 -0
- package/src/generators/configuration/lib/create-files.js +47 -0
- package/src/generators/configuration/lib/create-jest-config.d.ts +3 -0
- package/src/generators/configuration/lib/create-jest-config.js +102 -0
- package/src/generators/configuration/lib/ensure-dependencies.d.ts +3 -0
- package/src/generators/configuration/lib/ensure-dependencies.js +34 -0
- package/src/generators/configuration/lib/update-jestconfig.d.ts +3 -0
- package/src/generators/configuration/lib/update-jestconfig.js +26 -0
- package/src/generators/configuration/lib/update-tsconfig.d.ts +3 -0
- package/src/generators/configuration/lib/update-tsconfig.js +21 -0
- package/src/generators/configuration/lib/update-vscode-recommended-extensions.d.ts +2 -0
- package/src/generators/configuration/lib/update-vscode-recommended-extensions.js +18 -0
- package/src/generators/configuration/lib/update-workspace.d.ts +3 -0
- package/src/generators/configuration/lib/update-workspace.js +23 -0
- package/src/generators/configuration/schema.d.ts +31 -0
- package/src/generators/configuration/schema.json +80 -0
- package/src/generators/init/init.d.ts +5 -0
- package/src/generators/init/init.js +106 -0
- package/src/generators/init/schema.d.ts +8 -0
- package/src/generators/init/schema.json +35 -0
- package/src/migrations/update-15-0-0/add-jest-inputs.d.ts +2 -0
- package/src/migrations/update-15-0-0/add-jest-inputs.js +41 -0
- package/src/migrations/update-15-8-0/update-configs-jest-29.d.ts +3 -0
- package/src/migrations/update-15-8-0/update-configs-jest-29.js +146 -0
- package/src/migrations/update-15-8-0/update-tests-jest-29.d.ts +5 -0
- package/src/migrations/update-15-8-0/update-tests-jest-29.js +60 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/migrations/update-16-5-0/add-test-setup-to-inputs-ignore.d.ts +3 -0
- package/src/migrations/update-16-5-0/add-test-setup-to-inputs-ignore.js +18 -0
- package/src/migrations/update-17-1-0/move-options-to-target-defaults.d.ts +2 -0
- package/src/migrations/update-17-1-0/move-options-to-target-defaults.js +117 -0
- package/src/plugins/plugin.d.ts +6 -0
- package/src/plugins/plugin.js +130 -0
- package/src/utils/ast-utils.d.ts +9 -0
- package/src/utils/ast-utils.js +32 -0
- package/src/utils/config/find-root-jest-files.d.ts +3 -0
- package/src/utils/config/find-root-jest-files.js +23 -0
- package/src/utils/config/functions.d.ts +17 -0
- package/src/utils/config/functions.js +211 -0
- package/src/utils/config/get-jest-projects.d.ts +34 -0
- package/src/utils/config/get-jest-projects.js +157 -0
- package/src/utils/config/is-preset-cjs.d.ts +2 -0
- package/src/utils/config/is-preset-cjs.js +15 -0
- package/src/utils/config/update-config.d.ts +20 -0
- package/src/utils/config/update-config.js +83 -0
- package/src/utils/versions.d.ts +9 -0
- package/src/utils/versions.js +12 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-2023 Narwhal Technologies Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<p style="text-align: center;">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
|
|
4
|
+
<img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<div style="text-align: center;">
|
|
9
|
+
|
|
10
|
+
[](https://circleci.com/gh/nrwl/nx)
|
|
11
|
+
[]()
|
|
12
|
+
[](https://www.npmjs.com/@nx/workspace)
|
|
13
|
+
[]()
|
|
14
|
+
[](http://commitizen.github.io/cz-cli/)
|
|
15
|
+
[](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
16
|
+
[](https://go.nx.dev/community)
|
|
17
|
+
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
<hr>
|
|
22
|
+
|
|
23
|
+
# Nx: Smart Monorepos · Fast CI
|
|
24
|
+
|
|
25
|
+
Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
|
|
26
|
+
|
|
27
|
+
This package is a [Jest plugin for Nx](https://nx.dev/jest/overview).
|
|
28
|
+
|
|
29
|
+
## Getting Started
|
|
30
|
+
|
|
31
|
+
### Creating an Nx Workspace
|
|
32
|
+
|
|
33
|
+
**Using `npx`**
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx create-nx-workspace
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Using `npm init`**
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm init nx-workspace
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Using `yarn create`**
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
yarn create nx-workspace
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Adding Nx to an Existing Repository
|
|
52
|
+
|
|
53
|
+
Run:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npx nx@latest init
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Documentation & Resources
|
|
60
|
+
|
|
61
|
+
- [Nx.Dev: Documentation, Guides, Tutorials](https://nx.dev)
|
|
62
|
+
- [Intro to Nx](https://nx.dev/getting-started/intro)
|
|
63
|
+
- [Official Nx YouTube Channel](https://www.youtube.com/@NxDevtools)
|
|
64
|
+
- [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
|
|
65
|
+
|
|
66
|
+
<p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
|
|
67
|
+
width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
|
|
68
|
+
|
package/executors.json
ADDED
package/generators.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Nx Jest",
|
|
3
|
+
"version": "0.1",
|
|
4
|
+
"generators": {
|
|
5
|
+
"init": {
|
|
6
|
+
"factory": "./src/generators/init/init#jestInitGeneratorInternal",
|
|
7
|
+
"schema": "./src/generators/init/schema.json",
|
|
8
|
+
"description": "Initialize the `@nrwl/jest` plugin.",
|
|
9
|
+
"aliases": ["ng-add"],
|
|
10
|
+
"hidden": true
|
|
11
|
+
},
|
|
12
|
+
"configuration": {
|
|
13
|
+
"factory": "./src/generators/configuration/configuration#configurationGeneratorInternal",
|
|
14
|
+
"schema": "./src/generators/configuration/schema.json",
|
|
15
|
+
"description": "Add Jest configuration to a project.",
|
|
16
|
+
"hidden": true
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { configurationGenerator } from './src/generators/configuration/configuration';
|
|
2
|
+
export { configurationGenerator };
|
|
3
|
+
/** @deprecated Use `configurationGenerator` instead. */
|
|
4
|
+
export declare const jestProjectGenerator: typeof configurationGenerator;
|
|
5
|
+
export { addPropertyToJestConfig, removePropertyFromJestConfig, } from './src/utils/config/update-config';
|
|
6
|
+
export { jestConfigObjectAst } from './src/utils/config/functions';
|
|
7
|
+
export { jestInitGenerator } from './src/generators/init/init';
|
|
8
|
+
export { getJestProjects, getJestProjectsAsync, getNestedJestProjects, } from './src/utils/config/get-jest-projects';
|
package/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNestedJestProjects = exports.getJestProjectsAsync = exports.getJestProjects = exports.jestInitGenerator = exports.jestConfigObjectAst = exports.removePropertyFromJestConfig = exports.addPropertyToJestConfig = exports.jestProjectGenerator = exports.configurationGenerator = void 0;
|
|
4
|
+
const configuration_1 = require("./src/generators/configuration/configuration");
|
|
5
|
+
Object.defineProperty(exports, "configurationGenerator", { enumerable: true, get: function () { return configuration_1.configurationGenerator; } });
|
|
6
|
+
// Exported for backwards compatibility in case a plugin is using the old name.
|
|
7
|
+
/** @deprecated Use `configurationGenerator` instead. */
|
|
8
|
+
exports.jestProjectGenerator = configuration_1.configurationGenerator;
|
|
9
|
+
var update_config_1 = require("./src/utils/config/update-config");
|
|
10
|
+
Object.defineProperty(exports, "addPropertyToJestConfig", { enumerable: true, get: function () { return update_config_1.addPropertyToJestConfig; } });
|
|
11
|
+
Object.defineProperty(exports, "removePropertyFromJestConfig", { enumerable: true, get: function () { return update_config_1.removePropertyFromJestConfig; } });
|
|
12
|
+
var functions_1 = require("./src/utils/config/functions");
|
|
13
|
+
Object.defineProperty(exports, "jestConfigObjectAst", { enumerable: true, get: function () { return functions_1.jestConfigObjectAst; } });
|
|
14
|
+
var init_1 = require("./src/generators/init/init");
|
|
15
|
+
Object.defineProperty(exports, "jestInitGenerator", { enumerable: true, get: function () { return init_1.jestInitGenerator; } });
|
|
16
|
+
var get_jest_projects_1 = require("./src/utils/config/get-jest-projects");
|
|
17
|
+
Object.defineProperty(exports, "getJestProjects", { enumerable: true, get: function () { return get_jest_projects_1.getJestProjects; } });
|
|
18
|
+
Object.defineProperty(exports, "getJestProjectsAsync", { enumerable: true, get: function () { return get_jest_projects_1.getJestProjectsAsync; } });
|
|
19
|
+
Object.defineProperty(exports, "getNestedJestProjects", { enumerable: true, get: function () { return get_jest_projects_1.getNestedJestProjects; } });
|
package/migrations.json
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generators": {
|
|
3
|
+
"add-jest-inputs": {
|
|
4
|
+
"version": "15.0.0-beta.0",
|
|
5
|
+
"cli": "nx",
|
|
6
|
+
"description": "Stop hashing jest spec files and config files for build targets and dependent tasks",
|
|
7
|
+
"factory": "./src/migrations/update-15-0-0/add-jest-inputs"
|
|
8
|
+
},
|
|
9
|
+
"update-configs-jest-29": {
|
|
10
|
+
"version": "15.8.0-beta.0",
|
|
11
|
+
"cli": "nx",
|
|
12
|
+
"description": "Update jest configs to support jest 29 changes (https://jestjs.io/docs/upgrading-to-jest29)",
|
|
13
|
+
"factory": "./src/migrations/update-15-8-0/update-configs-jest-29"
|
|
14
|
+
},
|
|
15
|
+
"update-tests-jest-29": {
|
|
16
|
+
"version": "15.8.0-beta.0",
|
|
17
|
+
"cli": "nx",
|
|
18
|
+
"description": "Update jest test files to support jest 29 changes (https://jestjs.io/docs/upgrading-to-jest29)",
|
|
19
|
+
"factory": "./src/migrations/update-15-8-0/update-tests-jest-29"
|
|
20
|
+
},
|
|
21
|
+
"update-16-0-0-add-nx-packages": {
|
|
22
|
+
"cli": "nx",
|
|
23
|
+
"version": "16.0.0-beta.1",
|
|
24
|
+
"description": "Replace @nrwl/jest with @nx/jest",
|
|
25
|
+
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
|
|
26
|
+
},
|
|
27
|
+
"add-test-setup-to-inputs-ignore": {
|
|
28
|
+
"cli": "nx",
|
|
29
|
+
"version": "16.5.0-beta.2",
|
|
30
|
+
"description": "Add test-setup.ts to ignored files in production input",
|
|
31
|
+
"implementation": "./src/migrations/update-16-5-0/add-test-setup-to-inputs-ignore"
|
|
32
|
+
},
|
|
33
|
+
"move-options-to-target-defaults": {
|
|
34
|
+
"version": "17.1.0-beta.2",
|
|
35
|
+
"description": "Move jest executor options to nx.json targetDefaults",
|
|
36
|
+
"implementation": "./src/migrations/update-17-1-0/move-options-to-target-defaults"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"packageJsonUpdates": {
|
|
40
|
+
"15.0.1-beta.3": {
|
|
41
|
+
"version": "15.0.1-beta.3",
|
|
42
|
+
"packages": {
|
|
43
|
+
"jest-environment-jsdom": {
|
|
44
|
+
"version": "~28.1.1",
|
|
45
|
+
"addToPackageJson": "devDependencies"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"15.8.0": {
|
|
50
|
+
"version": "15.8.0-beta.0",
|
|
51
|
+
"packages": {
|
|
52
|
+
"jest": {
|
|
53
|
+
"version": "~29.4.1",
|
|
54
|
+
"alwaysAddToPackageJson": false
|
|
55
|
+
},
|
|
56
|
+
"@types/jest": {
|
|
57
|
+
"version": "~29.4.0",
|
|
58
|
+
"alwaysAddToPackageJson": false
|
|
59
|
+
},
|
|
60
|
+
"expect": {
|
|
61
|
+
"version": "~29.4.1",
|
|
62
|
+
"alwaysAddToPackageJson": false
|
|
63
|
+
},
|
|
64
|
+
"@jest/globals": {
|
|
65
|
+
"version": "~29.4.1",
|
|
66
|
+
"alwaysAddToPackageJson": false
|
|
67
|
+
},
|
|
68
|
+
"jest-jasmine2": {
|
|
69
|
+
"version": "~29.4.1",
|
|
70
|
+
"alwaysAddToPackageJson": false
|
|
71
|
+
},
|
|
72
|
+
"jest-environment-jsdom": {
|
|
73
|
+
"version": "~29.4.1",
|
|
74
|
+
"alwaysAddToPackageJson": false
|
|
75
|
+
},
|
|
76
|
+
"ts-jest": {
|
|
77
|
+
"version": "~29.0.5",
|
|
78
|
+
"alwaysAddToPackageJson": false
|
|
79
|
+
},
|
|
80
|
+
"babel-jest": {
|
|
81
|
+
"version": "~29.4.1",
|
|
82
|
+
"alwaysAddToPackageJson": false
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"16.0.0": {
|
|
87
|
+
"version": "16.0.0-beta.4",
|
|
88
|
+
"packages": {
|
|
89
|
+
"ts-jest": {
|
|
90
|
+
"version": "~29.1.0",
|
|
91
|
+
"alwaysAddToPackageJson": false
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"17.2.0": {
|
|
96
|
+
"version": "17.2.0-beta.2",
|
|
97
|
+
"packages": {
|
|
98
|
+
"@types/node": {
|
|
99
|
+
"version": "18.16.9",
|
|
100
|
+
"alwaysAddToPackageJson": false
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nx/jest",
|
|
3
|
+
"version": "0.0.0-pr-22179-271588f",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "The Nx Plugin for Jest contains executors and generators allowing your workspace to use the powerful Jest testing capabilities.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/nrwl/nx.git",
|
|
9
|
+
"directory": "packages/jest"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"Monorepo",
|
|
13
|
+
"Angular",
|
|
14
|
+
"React",
|
|
15
|
+
"Web",
|
|
16
|
+
"Node",
|
|
17
|
+
"Nest",
|
|
18
|
+
"Jest",
|
|
19
|
+
"Unit Testing",
|
|
20
|
+
"CLI"
|
|
21
|
+
],
|
|
22
|
+
"main": "./index.js",
|
|
23
|
+
"typings": "./index.d.ts",
|
|
24
|
+
"author": "Victor Savkin",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/nrwl/nx/issues"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://nx.dev",
|
|
30
|
+
"generators": "./generators.json",
|
|
31
|
+
"executors": "./executors.json",
|
|
32
|
+
"ng-update": {
|
|
33
|
+
"requirements": {},
|
|
34
|
+
"migrations": "./migrations.json"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@jest/reporters": "^29.4.1",
|
|
38
|
+
"@jest/test-result": "^29.4.1",
|
|
39
|
+
"@nx/devkit": "0.0.0-pr-22179-271588f",
|
|
40
|
+
"@nx/js": "0.0.0-pr-22179-271588f",
|
|
41
|
+
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
42
|
+
"chalk": "^4.1.0",
|
|
43
|
+
"identity-obj-proxy": "3.0.0",
|
|
44
|
+
"jest-config": "^29.4.1",
|
|
45
|
+
"jest-resolve": "^29.4.1",
|
|
46
|
+
"jest-util": "^29.4.1",
|
|
47
|
+
"minimatch": "9.0.3",
|
|
48
|
+
"resolve.exports": "1.1.0",
|
|
49
|
+
"tslib": "^2.3.0",
|
|
50
|
+
"yargs-parser": "21.1.1",
|
|
51
|
+
"@nrwl/jest": "0.0.0-pr-22179-271588f"
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
},
|
|
56
|
+
"type": "commonjs"
|
|
57
|
+
}
|
package/plugin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createNodes, createDependencies, JestPluginOptions, } from './src/plugins/plugin';
|
package/plugin.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDependencies = exports.createNodes = void 0;
|
|
4
|
+
var plugin_1 = require("./src/plugins/plugin");
|
|
5
|
+
Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
|
|
6
|
+
Object.defineProperty(exports, "createDependencies", { enumerable: true, get: function () { return plugin_1.createDependencies; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path_1 = require("path");
|
|
4
|
+
const resolve_exports_1 = require("resolve.exports");
|
|
5
|
+
let compilerSetup;
|
|
6
|
+
let ts;
|
|
7
|
+
function getCompilerSetup(rootDir) {
|
|
8
|
+
const tsConfigPath = ts.findConfigFile(rootDir, ts.sys.fileExists, 'tsconfig.spec.json') ||
|
|
9
|
+
ts.findConfigFile(rootDir, ts.sys.fileExists, 'tsconfig.test.json') ||
|
|
10
|
+
ts.findConfigFile(rootDir, ts.sys.fileExists, 'tsconfig.jest.json');
|
|
11
|
+
if (!tsConfigPath) {
|
|
12
|
+
console.error(`Cannot locate a tsconfig.spec.json. Please create one at ${rootDir}/tsconfig.spec.json`);
|
|
13
|
+
}
|
|
14
|
+
const readResult = ts.readConfigFile(tsConfigPath, ts.sys.readFile);
|
|
15
|
+
const config = ts.parseJsonConfigFileContent(readResult.config, ts.sys, (0, path_1.dirname)(tsConfigPath));
|
|
16
|
+
const compilerOptions = config.options;
|
|
17
|
+
const host = ts.createCompilerHost(compilerOptions, true);
|
|
18
|
+
return { compilerOptions, host };
|
|
19
|
+
}
|
|
20
|
+
module.exports = function (path, options) {
|
|
21
|
+
const ext = (0, path_1.extname)(path);
|
|
22
|
+
if (ext === '.css' || ext === '.scss' || ext === '.sass' || ext === '.less') {
|
|
23
|
+
return require.resolve('identity-obj-proxy');
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
try {
|
|
27
|
+
// Try to use the defaultResolver with default options
|
|
28
|
+
return options.defaultResolver(path, options);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
// Try to use the defaultResolver with a packageFilter
|
|
32
|
+
return options.defaultResolver(path, {
|
|
33
|
+
...options,
|
|
34
|
+
packageFilter: (pkg) => ({
|
|
35
|
+
...pkg,
|
|
36
|
+
main: pkg.main || pkg.es2015 || pkg.module,
|
|
37
|
+
}),
|
|
38
|
+
pathFilter: (pkg) => {
|
|
39
|
+
if (!pkg.exports) {
|
|
40
|
+
return path;
|
|
41
|
+
}
|
|
42
|
+
return (0, resolve_exports_1.resolve)(pkg, path) || path;
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
if (path === 'jest-sequencer-@jest/test-sequencer' ||
|
|
49
|
+
path === '@jest/test-sequencer') {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
// Fallback to using typescript
|
|
53
|
+
ts = ts || require('typescript');
|
|
54
|
+
compilerSetup = compilerSetup || getCompilerSetup(options.rootDir);
|
|
55
|
+
const { compilerOptions, host } = compilerSetup;
|
|
56
|
+
return ts.resolveModuleName(path, (0, path_1.join)(options.basedir, 'fake-placeholder.ts'), compilerOptions, host).resolvedModule.resolvedFileName;
|
|
57
|
+
}
|
|
58
|
+
};
|
package/preset/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nxPreset = void 0;
|
|
4
|
+
exports.nxPreset = {
|
|
5
|
+
// This is one of the patterns that jest finds by default https://jestjs.io/docs/configuration#testmatch-arraystring
|
|
6
|
+
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],
|
|
7
|
+
resolver: '@nx/jest/plugins/resolver',
|
|
8
|
+
moduleFileExtensions: ['ts', 'js', 'mjs', 'html'],
|
|
9
|
+
coverageReporters: ['html'],
|
|
10
|
+
transform: {
|
|
11
|
+
'^.+\\.(ts|js|html)$': [
|
|
12
|
+
'ts-jest',
|
|
13
|
+
{ tsconfig: '<rootDir>/tsconfig.spec.json' },
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
testEnvironment: 'jsdom',
|
|
17
|
+
/**
|
|
18
|
+
* manually set the exports names to load in common js, to mimic the behaviors of jest 27
|
|
19
|
+
* before jest didn't fully support package exports and would load in common js code (typically via main field). now jest 28+ will load in the browser esm code, but jest esm support is not fully supported.
|
|
20
|
+
* In this case we will tell jest to load in the common js code regardless of environment.
|
|
21
|
+
*
|
|
22
|
+
* this can be removed via just overriding this setting in it's usage
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* module.exports = {
|
|
26
|
+
* ...nxPreset,
|
|
27
|
+
* testEnvironmentOptions: {},
|
|
28
|
+
* }
|
|
29
|
+
*/
|
|
30
|
+
testEnvironmentOptions: {
|
|
31
|
+
customExportConditions: ['node', 'require', 'default'],
|
|
32
|
+
},
|
|
33
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JestExecutorOptions } from './schema';
|
|
2
|
+
import { Config } from '@jest/types';
|
|
3
|
+
import { ExecutorContext, TaskGraph } from '@nx/devkit';
|
|
4
|
+
import type { BatchResults } from 'nx/src/tasks-runner/batch/batch-messages';
|
|
5
|
+
export declare function jestExecutor(options: JestExecutorOptions, context: ExecutorContext): Promise<{
|
|
6
|
+
success: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function jestConfigParser(options: JestExecutorOptions, context: ExecutorContext, multiProjects?: boolean): Promise<Config.Argv>;
|
|
9
|
+
export default jestExecutor;
|
|
10
|
+
export declare function batchJest(taskGraph: TaskGraph, inputs: Record<string, JestExecutorOptions>, overrides: JestExecutorOptions, context: ExecutorContext): Promise<BatchResults>;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.batchJest = exports.jestConfigParser = exports.jestExecutor = void 0;
|
|
4
|
+
const jest_1 = require("jest");
|
|
5
|
+
const jest_config_1 = require("jest-config");
|
|
6
|
+
const reporters_1 = require("@jest/reporters");
|
|
7
|
+
const test_result_1 = require("@jest/test-result");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const devkit_1 = require("@nx/devkit");
|
|
11
|
+
const summary_1 = require("./summary");
|
|
12
|
+
const fs_1 = require("fs");
|
|
13
|
+
process.env.NODE_ENV ??= 'test';
|
|
14
|
+
async function jestExecutor(options, context) {
|
|
15
|
+
const config = await jestConfigParser(options, context);
|
|
16
|
+
const { results } = await (0, jest_1.runCLI)(config, [options.jestConfig]);
|
|
17
|
+
return { success: results.success };
|
|
18
|
+
}
|
|
19
|
+
exports.jestExecutor = jestExecutor;
|
|
20
|
+
function getExtraArgs(options, schema) {
|
|
21
|
+
const extraArgs = {};
|
|
22
|
+
for (const key of Object.keys(options)) {
|
|
23
|
+
if (!schema.properties[key]) {
|
|
24
|
+
extraArgs[key] = options[key];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return extraArgs;
|
|
28
|
+
}
|
|
29
|
+
async function jestConfigParser(options, context, multiProjects = false) {
|
|
30
|
+
let jestConfig;
|
|
31
|
+
// support passing extra args to jest cli supporting 3rd party plugins
|
|
32
|
+
// like 'jest-runner-groups' --group arg
|
|
33
|
+
const schema = await Promise.resolve().then(() => require('./schema.json'));
|
|
34
|
+
const extraArgs = getExtraArgs(options, schema);
|
|
35
|
+
const config = {
|
|
36
|
+
...extraArgs,
|
|
37
|
+
$0: undefined,
|
|
38
|
+
_: [],
|
|
39
|
+
config: options.config,
|
|
40
|
+
coverage: options.codeCoverage,
|
|
41
|
+
bail: options.bail,
|
|
42
|
+
ci: options.ci,
|
|
43
|
+
color: options.color,
|
|
44
|
+
detectOpenHandles: options.detectOpenHandles,
|
|
45
|
+
forceExit: options.forceExit,
|
|
46
|
+
logHeapUsage: options.logHeapUsage,
|
|
47
|
+
detectLeaks: options.detectLeaks,
|
|
48
|
+
json: options.json,
|
|
49
|
+
maxWorkers: options.maxWorkers,
|
|
50
|
+
onlyChanged: options.onlyChanged,
|
|
51
|
+
changedSince: options.changedSince,
|
|
52
|
+
outputFile: options.outputFile,
|
|
53
|
+
passWithNoTests: options.passWithNoTests,
|
|
54
|
+
runInBand: options.runInBand,
|
|
55
|
+
showConfig: options.showConfig,
|
|
56
|
+
silent: options.silent,
|
|
57
|
+
testLocationInResults: options.testLocationInResults,
|
|
58
|
+
testNamePattern: options.testNamePattern,
|
|
59
|
+
testPathPattern: options.testPathPattern,
|
|
60
|
+
testPathIgnorePatterns: options.testPathIgnorePatterns,
|
|
61
|
+
testTimeout: options.testTimeout,
|
|
62
|
+
colors: options.colors,
|
|
63
|
+
verbose: options.verbose,
|
|
64
|
+
testResultsProcessor: options.testResultsProcessor,
|
|
65
|
+
updateSnapshot: options.updateSnapshot,
|
|
66
|
+
useStderr: options.useStderr,
|
|
67
|
+
watch: options.watch,
|
|
68
|
+
watchAll: options.watchAll,
|
|
69
|
+
randomize: options.randomize,
|
|
70
|
+
};
|
|
71
|
+
if (!multiProjects) {
|
|
72
|
+
options.jestConfig = path.resolve(context.root, options.jestConfig);
|
|
73
|
+
jestConfig = (await (0, jest_config_1.readConfig)(config, options.jestConfig)).projectConfig;
|
|
74
|
+
}
|
|
75
|
+
// for backwards compatibility
|
|
76
|
+
if (options.setupFile && !multiProjects) {
|
|
77
|
+
const setupFilesAfterEnvSet = new Set([
|
|
78
|
+
...(jestConfig.setupFilesAfterEnv ?? []),
|
|
79
|
+
path.resolve(context.root, options.setupFile),
|
|
80
|
+
]);
|
|
81
|
+
config.setupFilesAfterEnv = Array.from(setupFilesAfterEnvSet);
|
|
82
|
+
}
|
|
83
|
+
if (options.testFile) {
|
|
84
|
+
config._.push(options.testFile);
|
|
85
|
+
}
|
|
86
|
+
if (options.findRelatedTests) {
|
|
87
|
+
const parsedTests = options.findRelatedTests
|
|
88
|
+
.split(',')
|
|
89
|
+
.map((s) => s.trim());
|
|
90
|
+
config._.push(...parsedTests);
|
|
91
|
+
config.findRelatedTests = true;
|
|
92
|
+
}
|
|
93
|
+
if (options.coverageDirectory) {
|
|
94
|
+
config.coverageDirectory = path.join(context.root, options.coverageDirectory);
|
|
95
|
+
}
|
|
96
|
+
if (options.clearCache) {
|
|
97
|
+
config.clearCache = true;
|
|
98
|
+
}
|
|
99
|
+
if (options.reporters && options.reporters.length > 0) {
|
|
100
|
+
config.reporters = options.reporters;
|
|
101
|
+
}
|
|
102
|
+
if (Array.isArray(options.coverageReporters) &&
|
|
103
|
+
options.coverageReporters.length > 0) {
|
|
104
|
+
config.coverageReporters = options.coverageReporters;
|
|
105
|
+
}
|
|
106
|
+
return config;
|
|
107
|
+
}
|
|
108
|
+
exports.jestConfigParser = jestConfigParser;
|
|
109
|
+
exports.default = jestExecutor;
|
|
110
|
+
async function batchJest(taskGraph, inputs, overrides, context) {
|
|
111
|
+
let configPaths = [];
|
|
112
|
+
let selectedProjects = [];
|
|
113
|
+
let projectsWithNoName = [];
|
|
114
|
+
for (const task of taskGraph.roots) {
|
|
115
|
+
let configPath = path.resolve(context.root, inputs[task].jestConfig);
|
|
116
|
+
configPaths.push(configPath);
|
|
117
|
+
/* The display name in the jest.config.js is the correct project name jest
|
|
118
|
+
* uses to determine projects. It is usually the same as the Nx projectName
|
|
119
|
+
* but it can be changed. The safest method is to extract the displayName
|
|
120
|
+
* from the config file, but skip the project if it does not exist. */
|
|
121
|
+
const displayNameValueRegex = new RegExp(/(['"]+.*['"])(?<=displayName+.*)/, 'g');
|
|
122
|
+
const fileContents = (0, fs_1.readFileSync)(configPath, { encoding: 'utf-8' });
|
|
123
|
+
if (!displayNameValueRegex.test(fileContents)) {
|
|
124
|
+
projectsWithNoName.push([task.split(':')[0], configPath]);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const displayName = fileContents
|
|
128
|
+
.match(displayNameValueRegex)
|
|
129
|
+
.map((value) => value.substring(1, value.length - 1))[0];
|
|
130
|
+
selectedProjects.push(displayName);
|
|
131
|
+
}
|
|
132
|
+
if (projectsWithNoName.length > 0) {
|
|
133
|
+
throw new Error((0, devkit_1.stripIndents) `Some projects do not have a "displayName" property. Jest Batch Mode requires this to be set. Please ensure this value is set.
|
|
134
|
+
|
|
135
|
+
Projects missing "displayName":
|
|
136
|
+
${projectsWithNoName.map(([project, configPath]) => ` - ${project} - ${configPath}\r\n`)}
|
|
137
|
+
You can learn more about this requirement from Jest here: https://jestjs.io/docs/cli#--selectprojects-project1--projectn`);
|
|
138
|
+
}
|
|
139
|
+
const parsedConfigs = await jestConfigParser(overrides, context, true);
|
|
140
|
+
const { globalConfig, results } = await (0, jest_1.runCLI)({
|
|
141
|
+
...parsedConfigs,
|
|
142
|
+
selectProjects: selectedProjects,
|
|
143
|
+
}, [devkit_1.workspaceRoot]);
|
|
144
|
+
const { configs } = await (0, jest_config_1.readConfigs)({ $0: undefined, _: [] }, configPaths);
|
|
145
|
+
const jestTaskExecutionResults = {};
|
|
146
|
+
for (let i = 0; i < taskGraph.roots.length; i++) {
|
|
147
|
+
let root = taskGraph.roots[i];
|
|
148
|
+
const aggregatedResults = (0, test_result_1.makeEmptyAggregatedTestResult)();
|
|
149
|
+
aggregatedResults.startTime = results.startTime;
|
|
150
|
+
let endTime;
|
|
151
|
+
const projectRoot = (0, path_1.join)(context.root, taskGraph.tasks[root].projectRoot);
|
|
152
|
+
let resultOutput = '';
|
|
153
|
+
for (const testResult of results.testResults) {
|
|
154
|
+
if (testResult.testFilePath.startsWith(projectRoot)) {
|
|
155
|
+
aggregatedResults.startTime = aggregatedResults.startTime
|
|
156
|
+
? Math.min(aggregatedResults.startTime, testResult.perfStats.start)
|
|
157
|
+
: testResult.perfStats.start;
|
|
158
|
+
endTime = endTime
|
|
159
|
+
? Math.max(testResult.perfStats.end, endTime)
|
|
160
|
+
: testResult.perfStats.end;
|
|
161
|
+
(0, test_result_1.addResult)(aggregatedResults, testResult);
|
|
162
|
+
resultOutput +=
|
|
163
|
+
'\n\r' +
|
|
164
|
+
reporters_1.utils.getResultHeader(testResult, globalConfig, configs[i]);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
aggregatedResults.numTotalTestSuites = aggregatedResults.testResults.length;
|
|
168
|
+
jestTaskExecutionResults[root] = {
|
|
169
|
+
startTime: aggregatedResults.startTime,
|
|
170
|
+
endTime,
|
|
171
|
+
success: aggregatedResults.numFailedTests === 0,
|
|
172
|
+
// TODO(caleb): getSummary assumed endTime is Date.now().
|
|
173
|
+
// might need to make own method to correctly set the endtime base on tests instead of _now_
|
|
174
|
+
terminalOutput: resultOutput + '\n\r\n\r' + (0, summary_1.getSummary)(aggregatedResults),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
return jestTaskExecutionResults;
|
|
178
|
+
}
|
|
179
|
+
exports.batchJest = batchJest;
|