@nx/jest 18.4.0-canary.20240418-e549ea2 → 19.0.0-beta.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/jest",
3
- "version": "18.4.0-canary.20240418-e549ea2",
3
+ "version": "19.0.0-beta.1",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Jest contains executors and generators allowing your workspace to use the powerful Jest testing capabilities.",
6
6
  "repository": {
@@ -36,8 +36,8 @@
36
36
  "dependencies": {
37
37
  "@jest/reporters": "^29.4.1",
38
38
  "@jest/test-result": "^29.4.1",
39
- "@nx/devkit": "18.4.0-canary.20240418-e549ea2",
40
- "@nx/js": "18.4.0-canary.20240418-e549ea2",
39
+ "@nx/devkit": "19.0.0-beta.1",
40
+ "@nx/js": "19.0.0-beta.1",
41
41
  "@phenomnomnominal/tsquery": "~5.0.1",
42
42
  "chalk": "^4.1.0",
43
43
  "identity-obj-proxy": "3.0.0",
@@ -48,7 +48,7 @@
48
48
  "resolve.exports": "1.1.0",
49
49
  "tslib": "^2.3.0",
50
50
  "yargs-parser": "21.1.1",
51
- "@nrwl/jest": "18.4.0-canary.20240418-e549ea2"
51
+ "@nrwl/jest": "19.0.0-beta.1"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"
@@ -67,11 +67,24 @@ exports.createNodes = [
67
67
  };
68
68
  },
69
69
  ];
70
+ const jestValidatePath = (0, path_1.dirname)(require.resolve('jest-validate/package.json', {
71
+ paths: [(0, path_1.dirname)(require.resolve('jest-config'))],
72
+ }));
70
73
  async function buildJestTargets(configFilePath, projectRoot, options, context) {
74
+ const absConfigFilePath = (0, path_1.resolve)(context.workspaceRoot, configFilePath);
75
+ if (require.cache[absConfigFilePath]) {
76
+ for (const k of Object.keys(require.cache)) {
77
+ // Only delete the cache outside of jest-validate
78
+ // jest-validate has a Symbol which is important for jest config validation which breaks if the require cache is broken
79
+ if ((0, path_1.relative)(jestValidatePath, k).startsWith('../')) {
80
+ delete require.cache[k];
81
+ }
82
+ }
83
+ }
71
84
  const config = await (0, jest_config_1.readConfig)({
72
85
  _: [],
73
86
  $0: undefined,
74
- }, (0, path_1.resolve)(context.workspaceRoot, configFilePath));
87
+ }, absConfigFilePath);
75
88
  const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
76
89
  const targets = {};
77
90
  const target = (targets[options.targetName] = {
@@ -97,11 +110,11 @@ async function buildJestTargets(configFilePath, projectRoot, options, context) {
97
110
  paths: [(0, path_1.dirname)(jestPath)],
98
111
  // nx-ignore-next-line
99
112
  }));
100
- const context = await Runtime.createContext(config.projectConfig, {
113
+ const jestContext = await Runtime.createContext(config.projectConfig, {
101
114
  maxWorkers: 1,
102
115
  watchman: false,
103
116
  });
104
- const source = new jest.SearchSource(context);
117
+ const source = new jest.SearchSource(jestContext);
105
118
  const specs = await source.getTestPaths(config.globalConfig);
106
119
  const testPaths = new Set(specs.tests.map(({ path }) => path));
107
120
  if (testPaths.size > 0) {
@@ -126,7 +139,7 @@ async function buildJestTargets(configFilePath, projectRoot, options, context) {
126
139
  };
127
140
  targetGroup.push(options.ciTargetName);
128
141
  for (const testPath of testPaths) {
129
- const relativePath = (0, path_1.normalize)((0, path_1.relative)(projectRoot, testPath));
142
+ const relativePath = (0, path_1.normalize)((0, path_1.relative)((0, path_1.join)(context.workspaceRoot, projectRoot), testPath));
130
143
  const targetName = `${options.ciTargetName}--${relativePath}`;
131
144
  dependsOn.push(targetName);
132
145
  targets[targetName] = {