bahmutov / cypress-select-tests

User space solution for picking Cypress tests to run
96 stars 14 forks source link

Plugin immediately crashes after trying it for the first time. #206

Open jedicwb opened 3 years ago

jedicwb commented 3 years ago

Hi, I've done exactly what it says in the getting started instructions, that is, adding thecypress-select-tests and adding the plugin lines into my \cypress\plugins\index.js file.

After trying the regular npx cypress open --env grep=something in my project run crashes with:

Title: Error running plugin

Message: The following error was thrown by a plugin. We stopped running your tests because a plugin crashed. Please check your plugins file (...\takeaway-test-automation-assignment\cypress\plugins\index.js)

Details: SyntaxError: Unexpected token (2:14) at Parser.pp$4.raise (...\node_modules\acorn\dist\acorn.js:2927:15) at Parser.pp.unexpected (...t\node_modules\acorn\dist\acorn.js:698:10) at Parser.pp.semicolon (...\node_modules\acorn\dist\acorn.js:675:66) at Parser.pp$1.parseExpressionStatement (...\node_modules\acorn\dist\acorn.js:1154:10) at Parser.pp$1.parseStatement (...\node_modules\acorn\dist\acorn.js:889:26) at Parser.pp$1.parseBlock (...\node_modules\acorn\dist\acorn.js:1170:23) at Parser.pp$1.parseStatement (...\node_modules\acorn\dist\acorn.js:854:36) at Parser.pp$1.parseTopLevel (...\acorn\dist\acorn.js:755:23) at Parser.parse (...\node_modules\acorn\dist\acorn.js:555:17) at Function.parse (...\node_modules\acorn\dist\acorn.js:578:37) at Object.parse (...\node_modules\acorn\dist\acorn.js:5143:19) at module.exports (...\node_modules\falafel\index.js:23:22) at Object.findTests (...\node_modules\cypress-select-tests\src\spec-parser.js:95:3) at process (...\node_modules\cypress-select-tests\src\itify.js:18:33) at Stream.onend (...\node_modules\cypress-select-tests\src\itify.js:52:18) at _end (...\node_modules\through\index.js:65:9) at Stream.stream.end (...\node_modules\through\index.js:74:5) at DestroyableTransform.onend (...\node_modules\readable-stream\lib_stream_readable.js:577:10) at Object.onceWrapper (events.js:421:28) at DestroyableTransform.emit (events.js:327:22) at endReadableNT (...\node_modules\readable-stream\lib_stream_readable.js:1010:12) at processTicksAndRejections (internal/process/task_queues.js:84:21)

Stack trace:

Error: The following error was thrown by a plugin. We stopped running your tests because a plugin crashed. Please check your plugins file (`...\cypress\plugins\index.js`)
    at Object.get (...\AppData\Local\Cypress\Cache\6.7.1\Cypress\resources\app\packages\server\lib\errors.js:986:15)
    at EventEmitter.handleError (...\AppData\Local\Cypress\Cache\6.7.1\Cypress\resources\app\packages\server\lib\plugins\index.js:168:20)
    at EventEmitter.emit (events.js:315:20)
    at ChildProcess.<anonymous> (...\AppData\Local\Cypress\Cache\6.7.1\Cypress\resources\app\packages\server\lib\plugins\util.js:19:22)
    at ChildProcess.emit (events.js:315:20)
    at emit (internal/child_process.js:876:12)
    at processTicksAndRejections (internal/process/task_queues.js:85:21)

Am I doing something wrong?

dingraham01 commented 3 years ago

There are multiple other issues opened that reflect the same problem.

The only supposed workaround is to convert all the fixtures files from .json to .js files as explained here https://github.com/bahmutov/cypress-select-tests/issues/142

Doesn't seem to be any real solution outside of that. I have the same issue and problem as well which makes what I would consider a very useful tool to be unusable.

dingraham01 commented 3 years ago

@jedicwb @aqueezer @nimmala89 @samlucax @Ingewar

The problem is apparently related to the version of ECMAScript in the acorn.js file. Apparently the default version of 10 is unable to parse dynamic imports, which is throwing the confusing error.

I changed my ecmaVersion to 11, instead of the default version 10 and the issue is gone. image

This is where I got my solution https://github.com/acornjs/acorn/issues/970

The long-term solution would be fixing the cypress-select-tests plugin so it uses a version of acorn that has the upgraded ECMAVersion by default. In the meantime, I was able to get around and have my entire team get the patch too by using another plugin patch-package which automatically patches this dependency for anyone on my team using cypress-select-tests. Well worth the look I think. https://www.npmjs.com/package/patch-package

Sinnv2710 commented 3 years ago

Thanks @dingraham-dh , It's fixed when I change from 10 to 11