You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using cy.task fails when it is used along with TypeScript code which uses fully-specified ESM imports (imports using .js extension, where there is no matching .js file because all of the files are TypeScript files , see microsoft/TypeScript#41887 (comment)).
Note the difference in file names above. As per microsoft/TypeScript#41887 (comment), this should work in TypeScript (already works when using tsc)
Error message:
1) Employer sign up
should sign up with new company and verify email:
CypressError: `cy.task('deleteEmployer')` failed with the following error:
> Cannot find module '../util/connect.js'
Require stack:
- /Users/lukas/Documents/project/packages/database/queries/users.ts
- /Users/lukas/Documents/project/packages/website/cypress/plugins/index.ts
- /Users/lukas/Library/Caches/Cypress/9.5.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js
- /Users/lukas/Library/Caches/Cypress/9.5.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/index.js
https://on.cypress.io/api/task
at http://localhost:3020/__cypress/runner/cypress_runner.js:162240:78
at tryCatcher (http://localhost:3020/__cypress/runner/cypress_runner.js:13022:23)
at Promise._settlePromiseFromHandler (http://localhost:3020/__cypress/runner/cypress_runner.js:10957:31)
at Promise._settlePromise (http://localhost:3020/__cypress/runner/cypress_runner.js:11014:18)
at Promise._settlePromise0 (http://localhost:3020/__cypress/runner/cypress_runner.js:11059:10)
at Promise._settlePromises (http://localhost:3020/__cypress/runner/cypress_runner.js:11135:18)
at _drainQueueStep (http://localhost:3020/__cypress/runner/cypress_runner.js:7729:12)
at _drainQueue (http://localhost:3020/__cypress/runner/cypress_runner.js:7722:9)
at Async.../../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://localhost:3020/__cypress/runner/cypress_runner.js:7738:5)
at Async.drainQueues (http://localhost:3020/__cypress/runner/cypress_runner.js:7608:14)
From Your Spec Code:
at Context.eval (http://localhost:3020/__cypress/tests?p=cypress/integration/employerSignUp.spec.ts:188:10)
From Node.js Internals:
Error: Cannot find module '../util/connect.js'
Require stack:
- /Users/lukas/Documents/project/packages/database/queries/users.ts
- /Users/lukas/Documents/project/packages/website/cypress/plugins/index.ts
- /Users/lukas/Library/Caches/Cypress/9.5.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js
- /Users/lukas/Library/Caches/Cypress/9.5.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/index.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/lukas/Documents/project/packages/database/queries/users.ts:5:1)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Module.m._compile (/Users/lukas/Library/Caches/Cypress/9.5.1/Cypress.app/Contents/Resources/app/node_modules/ts-node/src/index.ts:607:4)
at Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
at Object.require.extensions.<computed> [as .ts] (/Users/lukas/Library/Caches/Cypress/9.5.1/Cypress.app/Contents/Resources/app/node_modules/ts-node/src/index.ts:610:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at /Users/lukas/Documents/project/packages/website/cypress/plugins/index.ts:30:37
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at deleteEmployer (/Users/lukas/Documents/project/packages/website/cypress/plugins/index.ts:30:37)
Desired behavior
Fully-specified ESM imports using .js file extensions should work in TypeScript code
Current behavior
Using
cy.taskfails when it is used along with TypeScript code which uses fully-specified ESM imports (imports using.jsextension, where there is no matching.jsfile because all of the files are TypeScript files , see microsoft/TypeScript#41887 (comment)).For example:
Note the difference in file names above. As per microsoft/TypeScript#41887 (comment), this should work in TypeScript (already works when using
tsc)Error message:
Desired behavior
Fully-specified ESM imports using
.jsfile extensions should work in TypeScript codeTwo details:
ts-nodefeat(register): resolve .js to .ts in ts-node/register TypeStrong/ts-node#13618.5.4version ofts-nodeis currently used in the macOS Cypress.app via theserverpackage (apparently? I was surprised to find it there):cypress/packages/server/package.json
Line 115 in 024308b
Test code to reproduce
See above
Cypress Version
9.5.1
Other
It would be nice if Cypress also supported Node.js ESM code just generally, but I think there are other issues for that: