diff --git a/packages/server/__snapshots__/1_typescript_support_spec.ts.js b/packages/server/__snapshots__/1_typescript_support_spec.ts.js deleted file mode 100644 index ca30a3c3a0d7..000000000000 --- a/packages/server/__snapshots__/1_typescript_support_spec.ts.js +++ /dev/null @@ -1,259 +0,0 @@ -exports['e2e typescript spec passes 1'] = ` - -==================================================================================================== - - (Run Starting) - - ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ Cypress: 1.2.3 │ - │ Browser: FooBrowser 88 │ - │ Specs: 1 found (typescript_passing_spec.ts) │ - │ Searched: cypress/integration/typescript_passing_spec.ts │ - └────────────────────────────────────────────────────────────────────────────────────────────────┘ - - -──────────────────────────────────────────────────────────────────────────────────────────────────── - - Running: typescript_passing_spec.ts (1 of 1) - - - imports work - ✓ foo coffee - ✓ bar babel - ✓ dom jsx - ✓ issue 7098 - - - 4 passing - - - (Results) - - ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ Tests: 4 │ - │ Passing: 4 │ - │ Failing: 0 │ - │ Pending: 0 │ - │ Skipped: 0 │ - │ Screenshots: 0 │ - │ Video: true │ - │ Duration: X seconds │ - │ Spec Ran: typescript_passing_spec.ts │ - └────────────────────────────────────────────────────────────────────────────────────────────────┘ - - - (Video) - - - Started processing: Compressing to 32 CRF - - Finished processing: /XXX/XXX/XXX/cypress/videos/typescript_passing_spec.ts.mp4 (X second) - - -==================================================================================================== - - (Run Finished) - - - Spec Tests Passing Failing Pending Skipped - ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ ✔ typescript_passing_spec.ts XX:XX 4 4 - - - │ - └────────────────────────────────────────────────────────────────────────────────────────────────┘ - ✔ All specs passed! XX:XX 4 4 - - - - - -` - -exports['e2e typescript spec fails 1'] = ` - -==================================================================================================== - - (Run Starting) - - ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ Cypress: 1.2.3 │ - │ Browser: FooBrowser 88 │ - │ Specs: 1 found (typescript_failing_spec.ts) │ - │ Searched: cypress/integration/typescript_failing_spec.ts │ - └────────────────────────────────────────────────────────────────────────────────────────────────┘ - - -──────────────────────────────────────────────────────────────────────────────────────────────────── - - Running: typescript_failing_spec.ts (1 of 1) - -Oops...we found an error preparing this test file: - - /foo/bar/.projects/e2e/cypress/integration/typescript_failing_spec.ts - -The error was: - -Error: Webpack Compilation Error -./cypress/integration/typescript_failing_spec.tsXX:XX -Module parse failed: Unexpected token (4:19) -File was processed with these loaders: - * ../../../../node_modules/@cypress/webpack-batteries-included-preprocessor/node_modules/ts-loader/index.js -You may need an additional loader to handle the result of these loaders. -| // The code below is ignored by eslint -| // because it tests failing spec. -> describe('fail', - > ); -| - @ multi ./cypress/integration/typescript_failing_spec.ts main[0] - -/foo/bar/.projects/e2e/cypress/integration/typescript_failing_spec.ts -./cypress/integration/typescript_failing_spec.ts -[tsl] ERROR in /foo/bar/.projects/e2e/cypress/integration/typescript_failing_spec.ts(3,19) - TS1109: Expression expected. - @ multi ./cypress/integration/typescript_failing_spec.ts main[0] - -/foo/bar/.projects/e2e/cypress/integration/typescript_failing_spec.ts -./cypress/integration/typescript_failing_spec.ts -[tsl] ERROR in /foo/bar/.projects/e2e/cypress/integration/typescript_failing_spec.ts(3,21) - TS1109: Expression expected. - @ multi ./cypress/integration/typescript_failing_spec.ts main[0] - -This occurred while Cypress was compiling and bundling your test code. This is usually caused by: - -- A missing file or dependency -- A syntax error in the file or one of its dependencies - -Fix the error in your code and re-run your tests. - - (Results) - - ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ Tests: 0 │ - │ Passing: 0 │ - │ Failing: 1 │ - │ Pending: 0 │ - │ Skipped: 0 │ - │ Screenshots: 0 │ - │ Video: true │ - │ Duration: X seconds │ - │ Spec Ran: typescript_failing_spec.ts │ - └────────────────────────────────────────────────────────────────────────────────────────────────┘ - - - (Video) - - - Started processing: Compressing to 32 CRF - - Finished processing: /XXX/XXX/XXX/cypress/videos/typescript_failing_spec.ts.mp4 (X second) - - -==================================================================================================== - - (Run Finished) - - - Spec Tests Passing Failing Pending Skipped - ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ ✖ typescript_failing_spec.ts XX:XX - - 1 - - │ - └────────────────────────────────────────────────────────────────────────────────────────────────┘ - ✖ 1 of 1 failed (100%) XX:XX - - 1 - - - - -` - -exports['e2e typescript project passes 1'] = ` - -==================================================================================================== - - (Run Starting) - - ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ Cypress: 1.2.3 │ - │ Browser: FooBrowser 88 │ - │ Specs: 2 found (app_spec.ts, math.ts) │ - └────────────────────────────────────────────────────────────────────────────────────────────────┘ - - -──────────────────────────────────────────────────────────────────────────────────────────────────── - - Running: app_spec.ts (1 of 2) - - - ✓ is true - - 1 passing - - - (Results) - - ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ Tests: 1 │ - │ Passing: 1 │ - │ Failing: 0 │ - │ Pending: 0 │ - │ Skipped: 0 │ - │ Screenshots: 0 │ - │ Video: true │ - │ Duration: X seconds │ - │ Spec Ran: app_spec.ts │ - └────────────────────────────────────────────────────────────────────────────────────────────────┘ - - - (Video) - - - Started processing: Compressing to 32 CRF - - Finished processing: /XXX/XXX/XXX/cypress/videos/app_spec.ts.mp4 (X second) - - -──────────────────────────────────────────────────────────────────────────────────────────────────── - - Running: math.ts (2 of 2) - - - 0 passing - - - (Results) - - ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ Tests: 0 │ - │ Passing: 0 │ - │ Failing: 0 │ - │ Pending: 0 │ - │ Skipped: 0 │ - │ Screenshots: 0 │ - │ Video: true │ - │ Duration: X seconds │ - │ Spec Ran: math.ts │ - └────────────────────────────────────────────────────────────────────────────────────────────────┘ - - - (Video) - - - Started processing: Compressing to 32 CRF - - Finished processing: /XXX/XXX/XXX/cypress/videos/math.ts.mp4 (X second) - - -==================================================================================================== - - (Run Finished) - - - Spec Tests Passing Failing Pending Skipped - ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ ✔ app_spec.ts XX:XX 1 1 - - - │ - ├────────────────────────────────────────────────────────────────────────────────────────────────┤ - │ ✔ math.ts XX:XX - - - - - │ - └────────────────────────────────────────────────────────────────────────────────────────────────┘ - ✔ All specs passed! XX:XX 1 1 - - - - - -` - -exports['typescript with tsconfig run'] = ` - (Run Finished) - - - Spec Tests Passing Failing Pending Skipped - ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ ✔ app_spec.ts XX:XX 1 1 - - - │ - ├────────────────────────────────────────────────────────────────────────────────────────────────┤ - │ ✔ js-spec.js XX:XX 2 2 - - - │ - ├────────────────────────────────────────────────────────────────────────────────────────────────┤ - │ ✔ math.ts XX:XX - - - - - │ - └────────────────────────────────────────────────────────────────────────────────────────────────┘ - ✔ All specs passed! XX:XX 3 3 - - - - - -` diff --git a/packages/server/lib/util/ts-node.js b/packages/server/lib/util/ts-node.js index 0c4ce0893a90..fa81234c9b24 100644 --- a/packages/server/lib/util/ts-node.js +++ b/packages/server/lib/util/ts-node.js @@ -7,7 +7,6 @@ const getTsNodeOptions = (tsPath) => { compiler: tsPath, // use the user's installed typescript compilerOptions: { module: 'CommonJS', - esModuleInterop: true, }, transpileOnly: true, // transpile only (no type-check) for speed } diff --git a/packages/server/test/e2e/1_typescript_plugins_spec.ts b/packages/server/test/e2e/1_typescript_plugins_spec.ts index 1b443dd13209..0661d55619d7 100644 --- a/packages/server/test/e2e/1_typescript_plugins_spec.ts +++ b/packages/server/test/e2e/1_typescript_plugins_spec.ts @@ -9,4 +9,11 @@ describe('e2e typescript in plugins file', function () { project: Fixtures.projectPath('ts-proj-with-module-esnext'), }) }) + + // https://github.com/cypress-io/cypress/issues/7575 + it('allows esModuleInterop to be overridden', function () { + return e2e.exec(this, { + project: Fixtures.projectPath('ts-proj-esmoduleinterop-false'), + }) + }) }) diff --git a/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress.json b/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress.json @@ -0,0 +1 @@ +{} diff --git a/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/integration/app_spec.ts b/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/integration/app_spec.ts new file mode 100644 index 000000000000..d09f3955c3e0 --- /dev/null +++ b/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/integration/app_spec.ts @@ -0,0 +1,3 @@ +it('dummy', () => { + expect(1 + 1).to.eq(2) +}) diff --git a/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/plugins/add.js b/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/plugins/add.js new file mode 100644 index 000000000000..e84213f385f3 --- /dev/null +++ b/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/plugins/add.js @@ -0,0 +1 @@ +module.exports = (a, b) => a + b diff --git a/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/plugins/index.ts b/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/plugins/index.ts new file mode 100644 index 000000000000..2a39b6c7896d --- /dev/null +++ b/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/plugins/index.ts @@ -0,0 +1,13 @@ +/// + +// https://github.com/cypress-io/cypress/issues/7575 +// It is tested here because Cypress spec files and support/plugin files use different TypeScript settings. +// And we want to test if esModuleInterop can be overriden in support/plugin files. +import * as add from './add' + +add(1, 2) + +// Default Cypress plugin function +export default (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) => { + +} diff --git a/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/support/index.ts b/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/support/index.ts new file mode 100644 index 000000000000..42839d2bf901 --- /dev/null +++ b/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/support/index.ts @@ -0,0 +1,20 @@ +// *********************************************************** +// This example support/index.js is processed and +// loaded automatically before your test files. +// +// This is a great place to put global configuration and +// behavior that modifies Cypress. +// +// You can change the location of this file or turn off +// automatically serving support files with the +// 'supportFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/configuration +// *********************************************************** + +// Import commands.js using ES2015 syntax: +// import './commands' + +// Alternatively you can use CommonJS syntax: +// require('./commands') diff --git a/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/tsconfig.json b/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/tsconfig.json new file mode 100644 index 000000000000..013103b4445a --- /dev/null +++ b/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "esModuleInterop": false + } +} \ No newline at end of file diff --git a/packages/server/test/unit/project_spec.js b/packages/server/test/unit/project_spec.js index be4865e24531..1cae5ac3428c 100644 --- a/packages/server/test/unit/project_spec.js +++ b/packages/server/test/unit/project_spec.js @@ -354,7 +354,6 @@ This option will not have an effect in Some-other-name. Tests that rely on web s compiler: projTsPath, compilerOptions: { module: 'CommonJS', - esModuleInterop: true, }, }) })