Cypress 13, CypressError: `cy.task('currents:test:after:run')` failed
Closed this issue Β· 4 comments
Ido112 commented
Please confirm
- I have searched for duplicate or closed issues and discussions.
- I will include a minimal, self-contained set of instructions for consistently reproducing the issue.
- I will attach a full debug log, otherwise the issue will be closed with no response.
Environment information
# Put output below this line
System:
OS: macOS 14.0
CPU: (10) arm64 Apple M1 Max
Memory: 1.48 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
Browsers:
Chrome: 117.0.5938.149
Safari: 17.0
npmPackages:
@babel/core: 7.12.10 => 7.12.10
@cypress/angular: 0.0.0-development
@cypress/mount-utils: 0.0.0-development
@cypress/react: 0.0.0-development
@cypress/react18: 0.0.0-development
@cypress/svelte: 0.0.0-development
@cypress/vue: 0.0.0-development
@cypress/vue2: 0.0.0-development
aigle: 1.14.1 => 1.14.1
crypto: 1.0.1 => 1.0.1
cypress: ^13.3.0 => 13.3.0
cypress-cloud: ^2.0.0-beta.1 => 2.0.0-beta.1
cypress-terminal-report: 5.3.7 => 5.3.7
dotenv: 8.2.0 => 8.2.0
eslint-plugin-cypress: 2.12.1 => 2.12.1
lodash: 4.17.21 => 4.17.21
superagent: 6.1.0 => 6.1.0
typescript: 5.1.3 => 5.1.3
npmGlobalPackages:
corepack: 0.17.0
npm: 9.5.1
Describe the bug
Hello, I found another issue with Cypress 13 and currents,
I'm using the hook 'test:after:run', (https://docs.cypress.io/api/cypress-api/catalog-of-events#Cypress-Events)
when i use Cypress runner, it works perfectly, when i use the currents runner, its fails with this error message
image
Expected behavior
that the hook will work with currents also
Setup and Command
main.js file
import 'dotenv/config.js';
import { run } from 'cypress-cloud';
import _ from 'lodash';
import cleanUpTests from './src/components/CleanupTests.js';
await run({
projectId: '123',
browser: 'electron',
parallel: true,
record: true,
ciBuildId: _.split(process.env.HOSTNAME, '-').at(-2)
});
await cleanUpTests();
cypress.config.js
import fs from 'fs';
import { defineConfig } from 'cypress';
import { cloudPlugin } from 'cypress-cloud/plugin';
import { PspsService } from './src/services/index.js';
export default defineConfig({
retries: {
runMode: 5,
openMode: 1
},
viewportHeight: 950,
viewportWidth: 1700,
e2e: {
setupNodeEvents(on, config) {
on('before:run', async () => {
const paymentsMethods = await PspsService.init();
const jsonString = JSON.stringify(paymentsMethods, null, 2);
const filePath = './paymentMethods.json';
fs.writeFileSync(filePath, jsonString);
});
on('after:spec', (spec, results) => {
if (results && results.video && results.stats.failures === 0) {
fs.unlinkSync(results.video);
}
});
config.baseUrl = config.env.BACKEND_URL;
cloudPlugin(on, config);
return config;
},
video: true,
defaultCommandTimeout: 10000,
experimentalInteractiveRunEvents: true,
experimentalRunAllSpecs: true,
experimentalOriginDependencies: true,
experimentalMemoryManagement: true,
chromeWebSecurity: false,
supportFile: 'src/commands/index.js',
specPattern: 'src/components/**/*.cy.js'
}
});
Full log and debug output
// Put your logs below this line
Using config file: file:///Users/ido/Desktop/repos/***Pro/cypress/currents.config.cjs
Cypress-cloud version: 2.0.0-beta.1
Cypress version: 13.3.0
Discovered 16 spec files
Tags: false; Group: false; Parallel: true; Batch Size: 1
Connecting to cloud orchestration service...
π₯ Run URL: https://app.currents.dev/run/1088148819bdedf6
====================================================================================================
Running: src/components/Transactions/***/Payments.cy.js (1/16)
DevTools listening on ws://127.0.0.1:50071/devtools/browser/c4fed92a-d8de-4667-86a7-f6916a3274c4
2023-10-11 12:59:01.916 Cypress[41483:1041322] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.
(node:41497) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:41497) ExperimentalWarning: The Node.js specifier resolution flag is experimental. It could change or be removed at any time.
====================================================================================================
(Run Starting)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Cypress: 13.3.0 β
β Browser: Electron 114 (headless) β
β Node Version: v18.16.0 (/Users/ido/.nvm/versions/node/v18.16.0/bin/node) β
β Specs: 1 found (***/Payments.cy.js) β
β Searched: src/components/Transactions/***/Payments.cy.js β
β Experiments: experimentalInteractiveRunEvents=true,experimentalRunAllSpecs=true,experimentβ¦ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
[initAllPsps]
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Running: ***Payments.cy.js (1 of 1)
***Payments
(Attempt 1 of 6) 369 - ***Payments - ***Payments Service
(Attempt 1 of 6) 369 - ***Payments - ***Payments Service
(Attempt 2 of 6) 369 - ***Payments - ***Payments Service
(Attempt 2 of 6) 369 - ***Payments - ***Payments Service
(Attempt 3 of 6) 369 - ***Payments - ***Payments Service
(Attempt 3 of 6) 369 - ***Payments - ***Payments Service
(Attempt 4 of 6) 369 - ***Payments - ***Payments Service
(Attempt 4 of 6) 369 - ***Payments - ***Payments Service
(Attempt 5 of 6) 369 - ***Payments - ***Payments Service
(Attempt 5 of 6) 369 - ***Payments - ***Payments Service
1) "before each" hook for "369 - ***Payments - ***Payments Service"
2) "after each" hook for "369 - ***Payments - ***Payments Service"
0 passing (2s)
2 failing
1) ***Payments
"before each" hook for "369 - ***Payments - ***Payments Service":
CypressError: `cy.task('currents:test:before:run')` failed with the following error:
The 'task' event has not been registered in the setupNodeEvents method. You must register it before using cy.task()
Fix this in your setupNodeEvents method here:
/Users/ido/Desktop/repos/***Pro/cypress/cypress.config.js
https://on.cypress.io/api/task
Because this error occurred during a `before each` hook we are skipping all of the remaining tests.
at <unknown> (http://localhost:50073/__cypress/runner/cypress_runner.js:135288:72)
at tryCatcher (http://localhost:50073/__cypress/runner/cypress_runner.js:1807:23)
at Promise._settlePromiseFromHandler (http://localhost:50073/__cypress/runner/cypress_runner.js:1519:31)
at Promise._settlePromise (http://localhost:50073/__cypress/runner/cypress_runner.js:1576:18)
at Promise._settlePromise0 (http://localhost:50073/__cypress/runner/cypress_runner.js:1621:10)
at Promise._settlePromises (http://localhost:50073/__cypress/runner/cypress_runner.js:1697:18)
at _drainQueueStep (http://localhost:50073/__cypress/runner/cypress_runner.js:2407:12)
at _drainQueue (http://localhost:50073/__cypress/runner/cypress_runner.js:2400:9)
at Async._drainQueues (http://localhost:50073/__cypress/runner/cypress_runner.js:2416:5)
at Async.drainQueues (http://localhost:50073/__cypress/runner/cypress_runner.js:2286:14)
From Your Spec Code:
at sendTestBeforeMetrics (webpack://cypress/./node_modules/cypress-cloud/support/index.js:74:0)
at handleBefore (webpack://cypress/./node_modules/cypress-cloud/support/index.js:88:0)
at Context.eval (webpack://cypress/./node_modules/cypress-cloud/support/index.js:100:0)
2) ***Payments
"after each" hook for "369 - ***Payments - ***Payments Service":
CypressError: `cy.task('currents:test:after:run')` failed with the following error:
The 'task' event has not been registered in the setupNodeEvents method. You must register it before using cy.task()
Fix this in your setupNodeEvents method here:
/Users/ido/Desktop/repos/***Pro/cypress/cypress.config.js
https://on.cypress.io/api/task
Because this error occurred during a `after each` hook we are skipping all of the remaining tests.
at <unknown> (http://localhost:50073/__cypress/runner/cypress_runner.js:135288:72)
at tryCatcher (http://localhost:50073/__cypress/runner/cypress_runner.js:1807:23)
at Promise._settlePromiseFromHandler (http://localhost:50073/__cypress/runner/cypress_runner.js:1519:31)
at Promise._settlePromise (http://localhost:50073/__cypress/runner/cypress_runner.js:1576:18)
at Promise._settlePromise0 (http://localhost:50073/__cypress/runner/cypress_runner.js:1621:10)
at Promise._settlePromises (http://localhost:50073/__cypress/runner/cypress_runner.js:1697:18)
at _drainQueueStep (http://localhost:50073/__cypress/runner/cypress_runner.js:2407:12)
at _drainQueue (http://localhost:50073/__cypress/runner/cypress_runner.js:2400:9)
at Async._drainQueues (http://localhost:50073/__cypress/runner/cypress_runner.js:2416:5)
at Async.drainQueues (http://localhost:50073/__cypress/runner/cypress_runner.js:2286:14)
From Your Spec Code:
at sendTestAfterMetrics (webpack://cypress/./node_modules/cypress-cloud/support/index.js:68:0)
at handleAfter (webpack://cypress/./node_modules/cypress-cloud/support/index.js:83:0)
at Context.eval (webpack://cypress/./node_modules/cypress-cloud/support/index.js:94:0)
agoldis commented
@Ido112 please try adding await
before cloudPlugin(on, config);
Also, please check out https://github.com/currents-dev/cypress-cloud#setup-with-existing-plugins
Ido112 commented
Ido112 commented
the only plugin that i have issue with is cypress-cloud, i using 2.0.0-beta.1
arendjantetteroo commented
The first line gives the reason:
See #179 and the currents blog for details:
https://currents.dev/posts/v13-blocking