fix(testing): unset customConditions when running cypress tasks (#30709)
## Current Behavior Cypress e2e tasks in a workspace with the `customConditions` TypeScript compiler option set, fail with the error: ```bash TSError: ⨯ Unable to compile TypeScript: error TS5098: Option 'customConditions' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'. ``` This happens because Cypress forces ts-node to use `module: commonjs` and `moduleResolution: node10`, which is not compatible with the `customConditions` TypeScript compiler option. ## Expected Behavior Cypress e2e tasks in a workspace with the `customConditions` TypeScript compiler option set should work as expected. ## Related Issue(s) Fixes #
This commit is contained in:
parent
70f1e660c8
commit
b3c1404b02
@ -116,6 +116,9 @@ describe('@nx/cypress/plugin', () => {
|
|||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"cwd": ".",
|
"cwd": ".",
|
||||||
|
"env": {
|
||||||
|
"TS_NODE_COMPILER_OPTIONS": "{"customConditions":null}",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
"{projectRoot}/dist/videos",
|
"{projectRoot}/dist/videos",
|
||||||
@ -213,6 +216,9 @@ describe('@nx/cypress/plugin', () => {
|
|||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"cwd": ".",
|
"cwd": ".",
|
||||||
|
"env": {
|
||||||
|
"TS_NODE_COMPILER_OPTIONS": "{"customConditions":null}",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
"{projectRoot}/dist/videos",
|
"{projectRoot}/dist/videos",
|
||||||
@ -325,6 +331,9 @@ describe('@nx/cypress/plugin', () => {
|
|||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"cwd": ".",
|
"cwd": ".",
|
||||||
|
"env": {
|
||||||
|
"TS_NODE_COMPILER_OPTIONS": "{"customConditions":null}",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
"{projectRoot}/dist/videos",
|
"{projectRoot}/dist/videos",
|
||||||
@ -402,6 +411,9 @@ describe('@nx/cypress/plugin', () => {
|
|||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"cwd": ".",
|
"cwd": ".",
|
||||||
|
"env": {
|
||||||
|
"TS_NODE_COMPILER_OPTIONS": "{"customConditions":null}",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
"{projectRoot}/dist/videos/src-test-cy-ts",
|
"{projectRoot}/dist/videos/src-test-cy-ts",
|
||||||
|
|||||||
@ -262,11 +262,15 @@ async function buildCypressTargets(
|
|||||||
|
|
||||||
const targets: Record<string, TargetConfiguration> = {};
|
const targets: Record<string, TargetConfiguration> = {};
|
||||||
let metadata: ProjectConfiguration['metadata'];
|
let metadata: ProjectConfiguration['metadata'];
|
||||||
|
const tsNodeCompilerOptions = JSON.stringify({ customConditions: null });
|
||||||
|
|
||||||
if ('e2e' in cypressConfig) {
|
if ('e2e' in cypressConfig) {
|
||||||
targets[options.targetName] = {
|
targets[options.targetName] = {
|
||||||
command: `cypress run`,
|
command: `cypress run`,
|
||||||
options: { cwd: projectRoot },
|
options: {
|
||||||
|
cwd: projectRoot,
|
||||||
|
env: { TS_NODE_COMPILER_OPTIONS: tsNodeCompilerOptions },
|
||||||
|
},
|
||||||
cache: true,
|
cache: true,
|
||||||
inputs: getInputs(namedInputs),
|
inputs: getInputs(namedInputs),
|
||||||
outputs: getOutputs(projectRoot, cypressConfig, 'e2e'),
|
outputs: getOutputs(projectRoot, cypressConfig, 'e2e'),
|
||||||
@ -345,6 +349,7 @@ async function buildCypressTargets(
|
|||||||
)}`,
|
)}`,
|
||||||
options: {
|
options: {
|
||||||
cwd: projectRoot,
|
cwd: projectRoot,
|
||||||
|
env: { TS_NODE_COMPILER_OPTIONS: tsNodeCompilerOptions },
|
||||||
},
|
},
|
||||||
parallelism: false,
|
parallelism: false,
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -392,7 +397,10 @@ async function buildCypressTargets(
|
|||||||
// This will not override the e2e target if it is the same
|
// This will not override the e2e target if it is the same
|
||||||
targets[options.componentTestingTargetName] ??= {
|
targets[options.componentTestingTargetName] ??= {
|
||||||
command: `cypress run --component`,
|
command: `cypress run --component`,
|
||||||
options: { cwd: projectRoot },
|
options: {
|
||||||
|
cwd: projectRoot,
|
||||||
|
env: { TS_NODE_COMPILER_OPTIONS: tsNodeCompilerOptions },
|
||||||
|
},
|
||||||
cache: true,
|
cache: true,
|
||||||
inputs: getInputs(namedInputs),
|
inputs: getInputs(namedInputs),
|
||||||
outputs: getOutputs(projectRoot, cypressConfig, 'component'),
|
outputs: getOutputs(projectRoot, cypressConfig, 'component'),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user