Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typescript compilerOptions "module" param breaks cypress #7151

Closed
yoavniran opened this issue Apr 27, 2020 · 4 comments · Fixed by #7197
Closed

typescript compilerOptions "module" param breaks cypress #7151

yoavniran opened this issue Apr 27, 2020 · 4 comments · Fixed by #7197
Labels
topic: typescript type: regression A bug that didn't appear until a specific Cy version release v4.4.0 🐛 Issue present since 4.4.0

Comments

@yoavniran
Copy link

yoavniran commented Apr 27, 2020

Current behavior:

In a JS project im working on I added TS type definitions for my packages.

for this I added a tsconfig.json to the root of my project. The "module" field in the config was accidentally set to "System".

When i committed my branch, cypress in CI started failing with an error:

ReferenceError: System is not defined

This was completely obscure to me and I couldnt figure out why it was failing since as far as i knew, ive made no change to Cypress.

Luckily, a search for the error found a similar (non Cypress related) that pointed me to the tsconfig.

Desired behavior:

Cypress shouldnt be affected by the tsconfig of the project using it or at the very least, the error should include useful information to help fix the problem

Test code to reproduce

repo can be found here:

https://github.com/rpldy/react-uploady/tree/ts-defs

setting the module field in tsconfig to "System" and running:
yarn e2e
will result in the aforementioned error.

Versions

cypress: 4.4.1

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Apr 28, 2020

I can reproduce this by:

This was introduced in Cypress 4.4.0 and it likely related to our out-of-the-box TypeScript support #5906

This project has no TypeScript files in cypress that it's running, so this is especially confusing as an error. cc @sainthkh

Workaround

Downgrade to Cypress 4.3.0

Full error:

/Users/jennifer/Library/Caches/Cypress/4.4.1/Cypress.app/Contents/Resources/app/packages/server/lib/exception.js:1
System.register([], function (exports_1, context_1) {
^

ReferenceError: System is not defined
    at Object.<anonymous> (/Users/jennifer/Library/Caches/Cypress/4.4.1/Cypress.app/Contents/Resources/app/packages/server/lib/exception.js:1:1)
    at Module._compile (internal/modules/cjs/loader.js:968:30)
    at Module.m._compile (/Users/jennifer/Library/Caches/Cypress/4.4.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/ts-node/src/index.ts:536:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:986:10)
    at Object.require.extensions.<computed> [as .js] (/Users/jennifer/Library/Caches/Cypress/4.4.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/ts-node/src/index.ts:539:12)
    at Module.load (internal/modules/cjs/loader.js:816:32)
    at Module._load (internal/modules/cjs/loader.js:728:14)
    at Module._load (electron/js2c/asar.js:717:26)
    at Function.Module._load (electron/js2c/asar.js:717:26)
    at Module.require (internal/modules/cjs/loader.js:853:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at exports.Logger.logger.createException (/Users/jennifer/Library/Caches/Cypress/4.4.1/Cypress.app/Contents/Resources/app/packages/server/lib/logger.js:67:12)
    at exports.Logger.logger.defaultErrorHandler (/Users/jennifer/Library/Caches/Cypress/4.4.1/Cypress.app/Contents/Resources/app/packages/server/lib/logger.js:92:12)
    at exports.Logger.exitOnError (/Users/jennifer/Library/Caches/Cypress/4.4.1/Cypress.app/Contents/Resources/app/packages/server/lib/logger.js:62:21)
    at exports.Logger.Logger._uncaughtException (/Users/jennifer/Library/Caches/Cypress/4.4.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/winston/lib/winston/logger.js:645:12)
    at process.emit (events.js:215:7)
    at processEmit (/Users/jennifer/Library/Caches/Cypress/4.4.1/Cypress.app/Contents/Resources/app/packages/launcher/node_modules/signal-exit/index.js:161:32)
    at process.emit (/Users/jennifer/Library/Caches/Cypress/4.4.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/source-map-support/source-map-support.js:485:21)
    at process._fatalException (internal/process/execution.js:150:25)

DEBUG log: system-not-defined.log

@jennifer-shehane jennifer-shehane added the v4.4.0 🐛 Issue present since 4.4.0 label Apr 28, 2020
@cypress-bot cypress-bot bot added the stage: needs investigating Someone from Cypress needs to look at this label Apr 28, 2020
@jennifer-shehane jennifer-shehane added the type: regression A bug that didn't appear until a specific Cy version release label Apr 28, 2020
@sainthkh
Copy link
Contributor

I'll check this out.

@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: needs investigating Someone from Cypress needs to look at this stage: work in progress stage: needs review The PR code is done & tested, needs review labels Apr 29, 2020
@cypress-bot cypress-bot bot added stage: ready for work The issue is reproducible and in scope stage: needs review The PR code is done & tested, needs review stage: work in progress and removed stage: work in progress stage: ready for work The issue is reproducible and in scope stage: needs review The PR code is done & tested, needs review labels May 1, 2020
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels May 4, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 4, 2020

The code for this is done in cypress-io/cypress#7197, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 20, 2020

Released in 4.6.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v4.6.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: typescript type: regression A bug that didn't appear until a specific Cy version release v4.4.0 🐛 Issue present since 4.4.0
Projects
None yet
3 participants