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

Allure for Cypress not working #934

Open
1 task done
harmin-parra opened this issue Apr 11, 2024 · 20 comments
Open
1 task done

Allure for Cypress not working #934

harmin-parra opened this issue Apr 11, 2024 · 20 comments
Assignees
Labels
theme:cypress type:bug Something isn't working

Comments

@harmin-parra
Copy link

harmin-parra commented Apr 11, 2024

Describe the Bug

I get this error when running cypress

Oops...we found an error preparing this test file:

  > cypress/support/e2e.js

The error was:

Error: Webpack Compilation Error
./cypress/support/e2e.js
Module not found: Error: Can't resolve 'allure-cypress/commands' in '/home/hpr/cypress-allure-plugin-example/cypress/support'
resolve 'allure-cypress/commands' in '/home/hpr/cypress-allure-plugin-example/cypress/support'
  Parsed request is a module
  using description file: /home/hpr/cypress-allure-plugin-example/package.json (relative path: ./cypress/support)
    Field 'browser' doesn't contain a valid alias configuration
    Looked for and couldn't find the file at the following paths:
[/home/hpr/cypress-allure-plugin-example/cypress/support/node_modules]
[/home/hpr/cypress-allure-plugin-example/cypress/node_modules]
[/home/hpr/node_modules]
[/home/node_modules]
[/node_modules]
[/home/hpr/cypress-allure-plugin-example/node_modules/allure-cypress/commands]
[/home/hpr/cypress-allure-plugin-example/node_modules/allure-cypress/commands.js]
[/home/hpr/cypress-allure-plugin-example/node_modules/allure-cypress/commands.json]
[/home/hpr/cypress-allure-plugin-example/node_modules/allure-cypress/commands.jsx]
[/home/hpr/cypress-allure-plugin-example/node_modules/allure-cypress/commands.mjs]
[/home/hpr/cypress-allure-plugin-example/node_modules/allure-cypress/commands.coffee]
 @ ./cypress/support/e2e.js 4:0-34
 
    at handle (/home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/@packages/server/node_modules/@cypress/webpack-preprocessor/dist/index.js:212:23)
    at finalCallback (/home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:257:39)
    at /home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:306:14
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (/home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/tapable/lib/Hook.js:154:20)
    at /home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:304:22
    at Compiler.emitRecords (/home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:499:39)
    at /home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:298:10
    at /home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:485:14
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (/home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/tapable/lib/Hook.js:154:20)
    at /home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:482:27
    at /home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/neo-async/async.js:2818:7
    at done (/home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/neo-async/async.js:3522:9)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (/home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/tapable/lib/Hook.js:154:20)
    at /home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:464:33
    at /home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/@packages/server/node_modules/graceful-fs/graceful-fs.js:143:16
    at /home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/@packages/server/node_modules/graceful-fs/graceful-fs.js:143:16
    at /home/hpr/.cache/Cypress/12.14.0/Cypress/resources/app/node_modules/@packages/server/node_modules/graceful-fs/graceful-fs.js:61:14
    at FSReqCallback.oncomplete (node:fs:192:23)

This occurred while Cypress was compiling and bundling your test code. This is usually caused by:

- A missing file or dependency
- A syntax error in the file or one of its dependencies

Fix the error in your code and re-run your tests.

Steps to Reproduce

npm install --save-dev allure-cypress

cypress/support/e2e.js file:

import './commands';
import "allure-cypress/commands";

cypress.config.js file:

const { defineConfig } = require('cypress');
const { allureCypress } = require("allure-cypress/reporter");

module.exports = defineConfig({
    video: false,
    e2e: {
        experimentalStudio: true,
        specPattern: 'cypress/tests/**/*.cy.{js,jsx,ts,tsx}',
        setupNodeEvents: async function (on, config) {
            allureCypress(on);
            return config;
        }
    }

npx cypress run

Expected Behaviour

cypress runs without errors and aluure report is generated

Screenshots or Additional Context

No response

What Language are you using?

JavaScript

What Framework/Allure Integration you are using?

allure-cypress 2.15.1

What version of Allure Integration you are using?

2.15.1

What version of Allure Report you are using?

2.27.0

Code of Conduct

  • I agree to follow this project's Code of Conduct
@harmin-parra harmin-parra added the type:bug Something isn't working label Apr 11, 2024
@bhadmusautomates
Copy link

I am experiencing the same issue, is there a solution in the near future?

@baev baev transferred this issue from allure-framework/allure2 May 8, 2024
@epszaw
Copy link
Member

epszaw commented May 14, 2024

Hey there! You don't need to import commands. Add just this import to make the integration works:

import "allure-cypress";

@epszaw epszaw self-assigned this May 14, 2024
epszaw added a commit that referenced this issue May 14, 2024
@bhadmus
Copy link

bhadmus commented May 14, 2024

Hey there! You don't need to import commands. Add just this import to make the integration works:

import "allure-cypress";

It doesn't work, the allure-results folder is empty

@epszaw
Copy link
Member

epszaw commented May 14, 2024

Could you provide the process log? Do you see any runtime error?

@bhadmus
Copy link

bhadmus commented May 14, 2024

Could you provide the process log? Do you see any runtime error?

0 verbose cli /Users/sanguine/.nvm/versions/node/v18.14.0/bin/node /Users/sanguine/.nvm/versions/node/v18.14.0/lib/node_modules/npm/bin/npm-cli.js
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 5ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:/Users/sanguine/.nvm/versions/node/v18.14.0/lib/node_modules/npm/npmrc Completed in 3ms
6 timing config:load:builtin Completed in 4ms
7 timing config:load:cli Completed in 0ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:/Users/sanguine/Tutorial/cohort-2/classes/week-one/.npmrc Completed in 0ms
10 timing config:load:project Completed in 1ms
11 timing config:load:file:/Users/sanguine/.npmrc Completed in 3ms
12 timing config:load:user Completed in 3ms
13 timing config:load:file:/Users/sanguine/.nvm/versions/node/v18.14.0/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:setEnvs Completed in 0ms
16 timing config:load Completed in 11ms
17 timing npm:load:configload Completed in 12ms
18 timing npm:load:mkdirpcache Completed in 0ms
19 timing npm:load:mkdirplogs Completed in 1ms
20 verbose title npm exec allure generate allure-results --clean
21 verbose argv "exec" "--" "allure" "generate" "allure-results" "--clean"
22 timing npm:load:setTitle Completed in 12ms
23 timing config:load:flatten Completed in 1ms
24 timing npm:load:display Completed in 2ms
25 verbose logfile logs-max:10 dir:/Users/sanguine/.npm/_logs/2024-05-14T22_23_05_029Z-
26 verbose logfile /Users/sanguine/.npm/_logs/2024-05-14T22_23_05_029Z-debug-0.log
27 timing npm:load:logFile Completed in 38ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 70ms
31 silly logfile start cleaning logs, removing 1 files
32 silly logfile done cleaning log files
33 timing arborist:ctor Completed in 0ms
34 timing arborist:ctor Completed in 1ms
35 http fetch GET 200 https://registry.npmjs.org/allure 627ms (cache revalidated)
36 timing command:exec Completed in 695ms
37 verbose stack Error: could not determine executable to run
37 verbose stack     at getBinFromManifest (/Users/sanguine/.nvm/versions/node/v18.14.0/lib/node_modules/npm/node_modules/libnpmexec/lib/get-bin-from-manifest.js:17:23)
37 verbose stack     at exec (/Users/sanguine/.nvm/versions/node/v18.14.0/lib/node_modules/npm/node_modules/libnpmexec/lib/index.js:187:15)
37 verbose stack     at async module.exports (/Users/sanguine/.nvm/versions/node/v18.14.0/lib/node_modules/npm/lib/cli.js:134:5)
38 verbose pkgid [email protected]
39 verbose cwd /Users/sanguine/Tutorial/cohort-2/classes/week-one
40 verbose Darwin 23.4.0
41 verbose node v18.14.0
42 verbose npm  v9.3.1
43 error could not determine executable to run
44 verbose exit 1
45 timing npm Completed in 778ms
46 verbose code 1
47 error A complete log of this run can be found in:
47 error     /Users/sanguine/.npm/_logs/2024-05-14T22_23_05_029Z-debug-0.log

@dayaneCsantos
Copy link

dayaneCsantos commented May 15, 2024

Ei! Você não precisa importar commands. Adicione apenas esta importação para fazer a integração funcionar:

import "allure-cypress";

Não funciona, a allure-resultspasta está vazia

@bhadmus I have the same problem, did you find any solution?

@bhadmus
Copy link

bhadmus commented May 15, 2024

@dayaneCsantos check my comment below. if it works for you, help me vote for my answer on stackoverflow as well https://stackoverflow.com/questions/77067015/cypress-allure-reports-are-not-getting-generated/78487640#78487640

@bhadmus
Copy link

bhadmus commented May 16, 2024

I eventually fixed this issue.

The workaround is to downgrade to v.2.14.0. If you're installing for the first time install using npm i -D [email protected] else just change the version to 2.14.0 in your package.json file then run npm i or yarn install.

Keep all config the same. i.e. import allure-cypress into the support\e2e.js using import 'allure-cypress/commands' and setting up allure-cypress in the cypress.config.js file like this:

const { allureCypress } = require("allure-cypress/reporter");

module.exports = defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      allureCypress(on)
    },
  },
});

run cypress in headless mode npx cypress run after this, the folder should be populated json files. to generate result, do not add npx to the allure command just use allure serve allure-results to create the result and view on a browser or use allure generate allure-results --clean to create a report folder containing the html version in the repository.

@epszaw
Copy link
Member

epszaw commented May 16, 2024

The problem has been already resolved in the next allure-cypress version. Stay in touch to get information about the new releases!

@RobertBattaglia
Copy link

Even following #934 (comment), I get build errors:

Error: Cannot find module 'allure-cypress/commands' from '/e2e/cypress/support' at /e2e/node_modules/resolve/lib/async.js:46:17 at process (/e2e/node_modules/resolve/lib/async.js:173:43) at ondir (/e2e/node_modules/resolve/lib/async.js:188:17) at load (/e2e/node_modules/resolve/lib/async.js:69:43) at onex (/e2e/node_modules/resolve/lib/async.js:92:31) at /e2e/node_modules/resolve/lib/async.js:22:47 at callback (/root/.cache/Cypress/13.4.0/Cypress/resources/app/node_modules/@packages/server/node_modules/graceful-fs/polyfills.js:299:20) at callback (/root/.cache/Cypress/13.4.0/Cypress/resources/app/node_modules/@packages/server/node_modules/graceful-fs/polyfills.js:299:20)

@bhadmus
Copy link

bhadmus commented May 16, 2024

Even following #934 (comment), I get build errors:

Error: Cannot find module 'allure-cypress/commands' from '/e2e/cypress/support' at /e2e/node_modules/resolve/lib/async.js:46:17 at process (/e2e/node_modules/resolve/lib/async.js:173:43) at ondir (/e2e/node_modules/resolve/lib/async.js:188:17) at load (/e2e/node_modules/resolve/lib/async.js:69:43) at onex (/e2e/node_modules/resolve/lib/async.js:92:31) at /e2e/node_modules/resolve/lib/async.js:22:47 at callback (/root/.cache/Cypress/13.4.0/Cypress/resources/app/node_modules/@packages/server/node_modules/graceful-fs/polyfills.js:299:20) at callback (/root/.cache/Cypress/13.4.0/Cypress/resources/app/node_modules/@packages/server/node_modules/graceful-fs/polyfills.js:299:20)

Are you trying to use it for Cucumber with Cypress? It doesn't work for it at the moment. I will like to fork this entire repo and see if I can make it work for Cucumber.js

@bhadmus
Copy link

bhadmus commented May 16, 2024

The problem has been already resolved in the next allure-cypress version. Stay in touch to get information about the new releases!

Looking forward to it

@RobertBattaglia
Copy link

Even following #934 (comment), I get build errors:
Error: Cannot find module 'allure-cypress/commands' from '/e2e/cypress/support' at /e2e/node_modules/resolve/lib/async.js:46:17 at process (/e2e/node_modules/resolve/lib/async.js:173:43) at ondir (/e2e/node_modules/resolve/lib/async.js:188:17) at load (/e2e/node_modules/resolve/lib/async.js:69:43) at onex (/e2e/node_modules/resolve/lib/async.js:92:31) at /e2e/node_modules/resolve/lib/async.js:22:47 at callback (/root/.cache/Cypress/13.4.0/Cypress/resources/app/node_modules/@packages/server/node_modules/graceful-fs/polyfills.js:299:20) at callback (/root/.cache/Cypress/13.4.0/Cypress/resources/app/node_modules/@packages/server/node_modules/graceful-fs/polyfills.js:299:20)

Are you trying to use it for Cucumber with Cypress? It doesn't work for it at the moment. I will like to fork this entire repo and see if I can make it work for Cucumber.js

No, not using Cucumber

@bhadmus
Copy link

bhadmus commented May 16, 2024

@RobertBattaglia use this for a workaround #934 (comment) until @epszaw releases the fix

@sadhishsk
Copy link

@dayaneCsantos check my comment below. if it works for you, help me vote for my answer on stackoverflow as well https://stackoverflow.com/questions/77067015/cypress-allure-reports-are-not-getting-generated/78487640#78487640

Made changes as per this comment but its not working in my case.

Facing this issue while running the scripts on CICD but works fine locally!

@sadhishsk
Copy link

The problem has been already resolved in the next allure-cypress version. Stay in touch to get information about the new releases!

Thank you for all the efforts! When can we expect a release @epszaw

@bhadmusautomates
Copy link

@dayaneCsantos check my comment below. if it works for you, help me vote for my answer on stackoverflow as well https://stackoverflow.com/questions/77067015/cypress-allure-reports-are-not-getting-generated/78487640#78487640

Made changes as per this comment but its not working in my case.

Facing this issue while running the scripts on CICD but works fine locally!

Can you share the pipeline error? I still used this in a class demo and it worked even with the v.2.15.0

@sadhishsk
Copy link

@bhadmus This is the error which I got:

**Oops...we found an error preparing this test file:

cypress/support/hooks.ts

The error was:

Error: Can't walk dependency graph: Cannot find module 'allure-cypress/commands' from '/e2e/cypress/support/hooks.ts'
required by /e2e/cypress/support/hooks.ts
at /e2e/node_modules/resolve/lib/async.js:146:35
at processDirs (/e2e/node_modules/resolve/lib/async.js:299:39)
at isdir (/e2e/node_modules/resolve/lib/async.js:306:32)
at /e2e/node_modules/resolve/lib/async.js:34:69
at callback (/root/node_modules/@packages/server/node_modules/graceful-fs/polyfills.js:299:20)
at callback (/root/node_modules/@packages/server/node_modules/graceful-fs/polyfills.js:299:20)
at FSReqCallback.oncomplete (node:fs:210:21)

This occurred while Cypress was compiling and bundling your test code. This is usually caused by:

  • A missing file or dependency
  • A syntax error in the file or one of its dependencies

Fix the error in your code and re-run your tests.**

@bhadmusautomates
Copy link

@sadhishsk let me see if I can replicate this in the pipeline

@dayaneCsantos
Copy link

@dayaneCsantos check my comment below. if it works for you, help me vote for my answer on stackoverflow as well https://stackoverflow.com/questions/77067015/cypress-allure-reports-are-not-getting-generated/78487640#78487640

Made changes as per this comment but its not working in my case.

Facing this issue while running the scripts on CICD but works fine locally!

Even following the instructions, it doesn't work. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme:cypress type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants