Comparing version 0.0.0-pr-29720-6055188 to 0.0.0-pr-29771-5e92bcc
{ | ||
"name": "@nx/jest", | ||
"version": "0.0.0-pr-29720-6055188", | ||
"version": "0.0.0-pr-29771-5e92bcc", | ||
"private": false, | ||
@@ -40,4 +40,4 @@ "description": "The Nx Plugin for Jest contains executors and generators allowing your workspace to use the powerful Jest testing capabilities.", | ||
"@jest/test-result": "^29.4.1", | ||
"@nx/devkit": "0.0.0-pr-29720-6055188", | ||
"@nx/js": "0.0.0-pr-29720-6055188", | ||
"@nx/devkit": "0.0.0-pr-29771-5e92bcc", | ||
"@nx/js": "0.0.0-pr-29771-5e92bcc", | ||
"@phenomnomnominal/tsquery": "~5.0.1", | ||
@@ -44,0 +44,0 @@ "identity-obj-proxy": "3.0.0", |
@@ -88,2 +88,11 @@ "use strict"; | ||
ignoreTestOutput(tree); | ||
// in the TS solution setup, the test target depends on the build outputs | ||
// so we need to setup the task pipeline accordingly | ||
const nxJson = (0, devkit_1.readNxJson)(tree); | ||
nxJson.targetDefaults ??= {}; | ||
nxJson.targetDefaults[options.targetName] ??= {}; | ||
nxJson.targetDefaults[options.targetName].dependsOn ??= []; | ||
nxJson.targetDefaults[options.targetName].dependsOn.push('^build'); | ||
nxJson.targetDefaults[options.targetName].dependsOn = Array.from(new Set(nxJson.targetDefaults[options.targetName].dependsOn)); | ||
(0, devkit_1.updateNxJson)(tree, nxJson); | ||
} | ||
@@ -90,0 +99,0 @@ if (!schema.skipFormat) { |
@@ -5,7 +5,7 @@ "use strict"; | ||
const devkit_1 = require("@nx/devkit"); | ||
const add_swc_config_1 = require("@nx/js/src/utils/swc/add-swc-config"); | ||
const path_1 = require("path"); | ||
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup"); | ||
function createFiles(tree, options, presetExt) { | ||
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project); | ||
const filesFolder = options.setupFile === 'angular' ? '../files-angular' : '../files'; | ||
const commonFilesFolder = options.setupFile === 'angular' ? '../files-angular' : '../files/common'; | ||
let transformer; | ||
@@ -18,3 +18,6 @@ let transformerOptions = null; | ||
transformer = '@swc/jest'; | ||
if (options.supportTsx) { | ||
if (options.isTsSolutionSetup) { | ||
transformerOptions = 'swcJestConfig'; | ||
} | ||
else if (options.supportTsx) { | ||
transformerOptions = | ||
@@ -28,3 +31,5 @@ "{ jsc: { parser: { syntax: 'typescript', tsx: true }, transform: { react: { runtime: 'automatic' } } } }"; | ||
} | ||
const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree); | ||
if (options.compiler === 'swc' && options.isTsSolutionSetup) { | ||
(0, add_swc_config_1.addSwcTestConfig)(tree, projectConfig.root, 'es6', options.supportTsx); | ||
} | ||
const projectRoot = options.rootProject | ||
@@ -34,9 +39,13 @@ ? options.project | ||
const rootOffset = (0, devkit_1.offsetFromRoot)(projectConfig.root); | ||
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, filesFolder), projectConfig.root, { | ||
// jsdom is the default in the nx preset | ||
const testEnvironment = options.testEnvironment === 'none' || options.testEnvironment === 'jsdom' | ||
? '' | ||
: options.testEnvironment; | ||
const coverageDirectory = options.isTsSolutionSetup | ||
? `test-output/jest/coverage` | ||
: `${rootOffset}coverage/${projectRoot}`; | ||
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, commonFilesFolder), projectConfig.root, { | ||
tmpl: '', | ||
...options, | ||
// jsdom is the default | ||
testEnvironment: options.testEnvironment === 'none' || options.testEnvironment === 'jsdom' | ||
? '' | ||
: options.testEnvironment, | ||
testEnvironment, | ||
transformer, | ||
@@ -49,11 +58,29 @@ transformerOptions, | ||
presetExt, | ||
coverageDirectory: isTsSolutionSetup | ||
? `test-output/jest/coverage` | ||
: `${rootOffset}coverage/${projectRoot}`, | ||
extendedConfig: isTsSolutionSetup | ||
coverageDirectory, | ||
extendedConfig: options.isTsSolutionSetup | ||
? `${rootOffset}tsconfig.base.json` | ||
: './tsconfig.json', | ||
outDir: isTsSolutionSetup ? `./out-tsc/jest` : `${rootOffset}dist/out-tsc`, | ||
module: !isTsSolutionSetup || transformer === 'ts-jest' ? 'commonjs' : undefined, | ||
outDir: options.isTsSolutionSetup | ||
? `./out-tsc/jest` | ||
: `${rootOffset}dist/out-tsc`, | ||
module: !options.isTsSolutionSetup || transformer === 'ts-jest' | ||
? 'commonjs' | ||
: undefined, | ||
}); | ||
if (options.setupFile !== 'angular') { | ||
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, options.isTsSolutionSetup | ||
? '../files/jest-config-ts-solution' | ||
: '../files/jest-config-non-ts-solution'), projectConfig.root, { | ||
tmpl: '', | ||
...options, | ||
testEnvironment, | ||
transformer, | ||
transformerOptions, | ||
js: !!options.js, | ||
rootProject: options.rootProject, | ||
offsetFromRoot: rootOffset, | ||
presetExt, | ||
coverageDirectory, | ||
}); | ||
} | ||
if (options.setupFile === 'none') { | ||
@@ -60,0 +87,0 @@ tree.delete((0, path_1.join)(projectConfig.root, './src/test-setup.ts')); |
@@ -7,2 +7,3 @@ "use strict"; | ||
const config_file_1 = require("../../../utils/config/config-file"); | ||
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup"); | ||
async function createJestConfig(tree, options, presetExt) { | ||
@@ -61,3 +62,5 @@ if (!tree.exists(`jest.preset.${presetExt}`)) { | ||
} | ||
const jestProjectConfig = `jest.config.${rootProjectConfig.projectType === 'application' ? 'app' : 'lib'}.${options.js ? 'js' : 'ts'}`; | ||
const jestProjectConfig = `jest.config.${(0, ts_solution_setup_1.getProjectType)(tree, rootProjectConfig.root, rootProjectConfig.projectType) === 'application' | ||
? 'app' | ||
: 'lib'}.${options.js ? 'js' : 'ts'}`; | ||
tree.rename(rootJestPath, jestProjectConfig); | ||
@@ -64,0 +67,0 @@ const nxJson = (0, devkit_1.readNxJson)(tree); |
@@ -5,4 +5,5 @@ "use strict"; | ||
const devkit_1 = require("@nx/devkit"); | ||
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup"); | ||
function updateTsConfig(host, options) { | ||
const { root, projectType } = (0, devkit_1.readProjectConfiguration)(host, options.project); | ||
const { root, projectType: _projectType } = (0, devkit_1.readProjectConfiguration)(host, options.project); | ||
if (!host.exists((0, devkit_1.joinPathFragments)(root, 'tsconfig.json'))) { | ||
@@ -20,2 +21,3 @@ throw new Error(`Expected ${(0, devkit_1.joinPathFragments)(root, 'tsconfig.json')} to exist. Please create one.`); | ||
}); | ||
const projectType = (0, ts_solution_setup_1.getProjectType)(host, root, _projectType); | ||
// fall-back runtime tsconfig file path in case the user didn't provide one | ||
@@ -22,0 +24,0 @@ let runtimeTsconfigPath = (0, devkit_1.joinPathFragments)(root, projectType === 'application' ? 'tsconfig.app.json' : 'tsconfig.lib.json'); |
154397
78
3216
+ Added@nx/devkit@0.0.0-pr-29771-5e92bcc(transitive)
+ Added@nx/js@0.0.0-pr-29771-5e92bcc(transitive)
+ Added@nx/nx-darwin-arm64@0.0.0-pr-29771-5e92bcc(transitive)
+ Added@nx/nx-darwin-x64@0.0.0-pr-29771-5e92bcc(transitive)
+ Added@nx/nx-freebsd-x64@0.0.0-pr-29771-5e92bcc(transitive)
+ Added@nx/nx-linux-arm-gnueabihf@0.0.0-pr-29771-5e92bcc(transitive)
+ Added@nx/nx-linux-arm64-gnu@0.0.0-pr-29771-5e92bcc(transitive)
+ Added@nx/nx-linux-arm64-musl@0.0.0-pr-29771-5e92bcc(transitive)
+ Added@nx/nx-linux-x64-gnu@0.0.0-pr-29771-5e92bcc(transitive)
+ Added@nx/nx-linux-x64-musl@0.0.0-pr-29771-5e92bcc(transitive)
+ Added@nx/nx-win32-arm64-msvc@0.0.0-pr-29771-5e92bcc(transitive)
+ Added@nx/nx-win32-x64-msvc@0.0.0-pr-29771-5e92bcc(transitive)
+ Added@nx/workspace@0.0.0-pr-29771-5e92bcc(transitive)
+ Addedbabel-plugin-macros@3.1.0(transitive)
+ Addedcosmiconfig@7.1.0(transitive)
+ Addednx@0.0.0-pr-29771-5e92bcc(transitive)
- Removed@nx/devkit@0.0.0-pr-29720-6055188(transitive)
- Removed@nx/js@0.0.0-pr-29720-6055188(transitive)
- Removed@nx/nx-darwin-arm64@0.0.0-pr-29720-6055188(transitive)
- Removed@nx/nx-darwin-x64@0.0.0-pr-29720-6055188(transitive)
- Removed@nx/nx-freebsd-x64@0.0.0-pr-29720-6055188(transitive)
- Removed@nx/nx-linux-arm-gnueabihf@0.0.0-pr-29720-6055188(transitive)
- Removed@nx/nx-linux-arm64-gnu@0.0.0-pr-29720-6055188(transitive)
- Removed@nx/nx-linux-arm64-musl@0.0.0-pr-29720-6055188(transitive)
- Removed@nx/nx-linux-x64-gnu@0.0.0-pr-29720-6055188(transitive)
- Removed@nx/nx-linux-x64-musl@0.0.0-pr-29720-6055188(transitive)
- Removed@nx/nx-win32-arm64-msvc@0.0.0-pr-29720-6055188(transitive)
- Removed@nx/nx-win32-x64-msvc@0.0.0-pr-29720-6055188(transitive)
- Removed@nx/workspace@0.0.0-pr-29720-6055188(transitive)
- Removedbabel-plugin-macros@2.8.0(transitive)
- Removedcosmiconfig@6.0.0(transitive)
- Removednx@0.0.0-pr-29720-6055188(transitive)