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

Cypress 13, CypressError: cy.task('currents:test:after:run') failed #188

Closed
3 tasks done
Ido112 opened this issue Oct 11, 2023 · 4 comments
Closed
3 tasks done

Cypress 13, CypressError: cy.task('currents:test:after:run') failed #188

Ido112 opened this issue Oct 11, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@Ido112
Copy link

Ido112 commented Oct 11, 2023

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)

@Ido112 Ido112 added the bug Something isn't working label Oct 11, 2023
@agoldis
Copy link
Contributor

agoldis commented Oct 11, 2023

@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
Copy link
Author

Ido112 commented Oct 12, 2023

ok. now on my local i not getting this error any more , but when i trying to run it on the cloud i getting
image

@Ido112
Copy link
Author

Ido112 commented Oct 12, 2023

the only plugin that i have issue with is cypress-cloud, i using 2.0.0-beta.1

@arendjantetteroo
Copy link
Contributor

The first line gives the reason:
See #179 and the currents blog for details:
https://currents.dev/posts/v13-blocking

@agoldis agoldis closed this as completed Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants