From c6d1d8e77c8bc44ab3b3dc332e32ad011bc448cb Mon Sep 17 00:00:00 2001 From: KHeo Date: Mon, 29 Jun 2020 13:53:22 +0900 Subject: [PATCH] Add e2e test. --- .../1_typescript_support_spec.ts.js | 13 ++++++++++++ .../test/e2e/1_typescript_support_spec.ts | 10 ++++++++++ .../cypress.json | 1 + .../cypress/integration/app_spec.ts | 5 +++++ .../cypress/integration/math.ts | 3 +++ .../cypress/plugins/index.ts | 9 +++++++++ .../cypress/plugins/math.js | 3 +++ .../cypress/support/index.ts | 20 +++++++++++++++++++ .../tsconfig.json | 3 +++ 9 files changed, 67 insertions(+) create mode 100644 packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress.json create mode 100644 packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/integration/app_spec.ts create mode 100644 packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/integration/math.ts create mode 100644 packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/plugins/index.ts create mode 100644 packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/plugins/math.js create mode 100644 packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/support/index.ts create mode 100644 packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/tsconfig.json diff --git a/packages/server/__snapshots__/1_typescript_support_spec.ts.js b/packages/server/__snapshots__/1_typescript_support_spec.ts.js index 3363bf4d83ca..4bc9565e7601 100644 --- a/packages/server/__snapshots__/1_typescript_support_spec.ts.js +++ b/packages/server/__snapshots__/1_typescript_support_spec.ts.js @@ -242,3 +242,16 @@ exports['typescript with tsconfig run'] = ` ` + +exports['e2e typescript esModuleInterop: false => direct import fails 1'] = ` +The plugins file is missing or invalid. + +Your \`pluginsFile\` is set to \`/foo/bar/.projects/ts-proj-esmoduleinterop-false/cypress/plugins/index.ts\`, but either the file is missing, it contains a syntax error, or threw an error when required. The \`pluginsFile\` must be a \`.js\` or \`.coffee\` file. + +Or you might have renamed the extension of your \`pluginsFile\` to \`.ts\`. If that's the case, restart the test runner. + +Please fix this, or set \`pluginsFile\` to \`false\` if a plugins file is not necessary for your project. + + TypeError: Cannot read property 'add' of undefined + [stack trace lines] +` diff --git a/packages/server/test/e2e/1_typescript_support_spec.ts b/packages/server/test/e2e/1_typescript_support_spec.ts index 3252ac68ba94..943a46c4b2a4 100644 --- a/packages/server/test/e2e/1_typescript_support_spec.ts +++ b/packages/server/test/e2e/1_typescript_support_spec.ts @@ -44,4 +44,14 @@ describe('e2e typescript', function () { snapshot('typescript with tsconfig run', runSummary) }) }) + + it('esModuleInterop: false => direct import fails', function () { + const projPath = Fixtures.projectPath('ts-proj-esmoduleinterop-false') + + return e2e.exec(this, { + project: projPath, + snapshot: true, + expectedExitCode: 1, + }) + }) }) 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..d539f78bfb6f --- /dev/null +++ b/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/integration/app_spec.ts @@ -0,0 +1,5 @@ +import { add } from './math' + +it('is true', () => { + expect(add(1, 2)).to.eq(3) +}) diff --git a/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/integration/math.ts b/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/integration/math.ts new file mode 100644 index 000000000000..e29e78dc31cf --- /dev/null +++ b/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/integration/math.ts @@ -0,0 +1,3 @@ +export const add = (a: number, b: number) => { + return 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..039ad6dc8e0c --- /dev/null +++ b/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/plugins/index.ts @@ -0,0 +1,9 @@ +/// + +import math from './math' + +math.add(1, 2) + +export default (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) => { + +} diff --git a/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/plugins/math.js b/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/plugins/math.js new file mode 100644 index 000000000000..f19ed79ad109 --- /dev/null +++ b/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/cypress/plugins/math.js @@ -0,0 +1,3 @@ +module.exports = { + add: (a, b) => a + b, +} 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..e9db6e43d0d8 --- /dev/null +++ b/packages/server/test/support/fixtures/projects/ts-proj-esmoduleinterop-false/tsconfig.json @@ -0,0 +1,3 @@ +{ + "esModuleInterop": false +} \ No newline at end of file