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

System generated cypress.config.ts issue #22034

Closed
santheep opened this issue Jun 2, 2022 · 7 comments · Fixed by #22058
Closed

System generated cypress.config.ts issue #22034

santheep opened this issue Jun 2, 2022 · 7 comments · Fixed by #22058
Assignees
Labels
v10.0.0 🐛 Issue present since 10.0.0

Comments

@santheep
Copy link

santheep commented Jun 2, 2022

Current behavior

upgraded successfully to cypress ver 10

after running cypress open

Select e2e Testing (not configured)

It recommends the following changes

  1. cypress.config.ts
  2. cypress\support\e2e.ts
  3. cypress\support\commands.ts

click continue
Throws Syntax error eventhough the default cypress.config.ts was system generated

--cypress.config.ts--

import { defineConfig } from "cypress";

export default defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      // implement node event listeners here
    },
  },
}); 

Desired behavior

IT should continue successfully

Test code to reproduce

SyntaxError

Your configFile is invalid: C:\GuiAutomation\cypress.config.ts

It threw an error when required, check the stack trace below:

[Stack trace](http://localhost:54487/__launchpad/index.html#)
C:\GuiAutomation\cypress.config.ts:1

import { defineConfig } from "cypress";
^^^^^^
Your configFile is invalid: C:\GuiAutomation\cypress.config.ts

It threw an error when required, check the stack trace below:

[Stack trace](http://localhost:54487/__launchpad/index.html#)
C:\GuiAutomation\cypress.config.ts:1
import { defineConfig } from "cypress";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:979:16)
    at Module._compile (internal/modules/cjs/loader.js:1027:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at loadFile (C:\Users\santh_lfly\AppData\Local\Cypress\Cache\10.0.1\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\run_require_async_child.js:103:14)
    at EventEmitter. (C:\Users\santh_lfly\AppData\Local\Cypress\Cache\10.0.1\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\run_require_async_child.js:146:38)
    at EventEmitter.emit (events.js:315:20)
    at EventEmitter.emit (domain.js:467:12)
    at process. (C:\Users\santh_lfly\AppData\Local\Cypress\Cache\10.0.1\Cypress\resources\app\node_modules\@packages\server\lib\plugins\util.js:33:22)
    at process.emit (events.js:315:20)
    at process.EventEmitter.emit (domain.js:467:12)
    at emit (internal/child_process.js:903:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)

Cypress Version

v10.0.1

Other

Cypress package version: 10.0.1
Cypress binary version: 10.0.1
Electron version: 18.0.4
Bundled Node version:
16.13.2

@lmiller1990
Copy link
Contributor

lmiller1990 commented Jun 2, 2022

Seems like a dup of #22038. See this comment: #22038 (comment)

Are you able to share your existing project? Ideally a repo we could clone, but if that's too much trouble, a package.json, cypress.json and cypress/plugins/index.js would be a good start.

@tgriesser
Copy link
Member

@santheep can you confirm whether you have typescript installed in your project? Also whether you have a tsconfig.json in your project's root directory? The issue may be that we're incorrectly scaffolding TS for projects that aren't using it - we should have a fix out for that issue today.

@jennifer-shehane jennifer-shehane added v10.0.0 🐛 Issue present since 10.0.0 stage: awaiting response Potential fix was proposed; awaiting response labels Jun 2, 2022
@RiZKiT
Copy link

RiZKiT commented Jun 2, 2022

We have the same issue and yes we have a tsconfig.json in our project, but just for linting and other reasons, no typescript installed.

@mjhenkes
Copy link
Member

mjhenkes commented Jun 2, 2022

@tgriesser, @lmiller1990 should we close this as a dupe of #22038?

@tgriesser
Copy link
Member

@mjhenkes no, they're separate issues - opening a fix for this one shortly

@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: awaiting response Potential fix was proposed; awaiting response labels Jun 2, 2022
@mjhenkes mjhenkes added the PATCH label Jun 2, 2022
tgriesser added a commit that referenced this issue Jun 2, 2022
* fix: changes to correct typescript detection behavior, fixes #22034

Co-authored-by: Matt Henkes <mjhenkes@gmail.com>
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 2, 2022

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

@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Jun 2, 2022
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 2, 2022

Released in 10.0.2.

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

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jun 2, 2022
@mjhenkes mjhenkes removed the PATCH label Jun 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
v10.0.0 🐛 Issue present since 10.0.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants