badeball / cypress-cucumber-preprocessor

Run cucumber/gherkin-syntaxed specs with Cypress
MIT License
1.32k stars 147 forks source link

Most logs are missing in cucumber-messages.ndjson when running test via self built docker image #1048

Closed huiyangns closed 1 year ago

huiyangns commented 1 year ago

Current behavior

I built a docker image to run test against our project. when finishing test, I found most logs are missing in cucumber-messages.ndjson. The file only contains two lines. So json and html report cannot be generated correctly image

As a comparison, if I run test directly without using docker image, everything is ok npx cypress run --env TAGS='@test' --headless --browser chrome --e2e image

Desired behavior

Expect cucumber-messages.ndjson contains the whole log

Test code to reproduce

  1. Here is the config in package.json

    "cypress-cucumber-preprocessor": {
    "stepDefinitions": [
      "tests/cypress/integration/common/**/*.js"
    ],
    "filterSpecs": true,
    "messages": {
      "enabled": true,
      "output": "tests/cypress/cucumber-json/cucumber-messages.ndjson"
    },
    "json": {
      "enabled": true,
      "formatter": "tests/cypress/cucumberJsonFormatter/cucumber-json-formatter",
      "output": "tests/cypress/cucumber-json/report.json"
    },
    "html": {
      "enabled": true,
      "output": "tests/cypress/cucumber-json/cucumber-report.html"
    }
    },
  2. Here is the docker file

    
    FROM cypress/browsers:node-18.16.0-chrome-113.0.5672.92-1-ff-113.0-edge-113.0.1774.35-1
    WORKDIR /app
    RUN npm install cypress@11.2.0
    RUN npm install @badeball/cypress-cucumber-preprocessor@14.0.0
    RUN npm install @bahmutov/cypress-esbuild-preprocessor@2.1.5
    RUN npm install esbuild@0.16.17
    RUN npm install cucumber-html-reporter@5.3.0
    RUN npm install cypress-dotenv@1.2.2
    RUN npm install cypress-file-upload@4.1.1
    RUN npm install cypress-localstorage-commands@1.7.0
    RUN npm install pdf-parse
    RUN npm i -D cypress-wait-until
    RUN npm install idb
    RUN npm install cypress-cloud
    RUN npm install pdfjs-dist
    RUN npm install auth0-js@^9.14.3
    RUN npm install moment@2.29.1
    RUN npm i node-poppler
    RUN apt-get update
    RUN apt-get install poppler-data -y
    RUN apt-get install poppler-utils -y
    RUN npx cypress verify

RUN chmod 755 /root ENV CYPRESS_CACHE_FOLDER=/root/.cache/Cypress

USER node


3. Here is debugging output

docker run --ipc=host --net test_default -v /test:/app -v /app/node_modules -w /app -it --rm cypress:test bash

node@0034608b232a:/app$ DEBUG=cypress:electron,cypress-configuration,cypress-cucumber-preprocessor npx cypress run --env TAGS='@test' --headless --bro wser chrome --e2e libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null) [890:0701/054702.987154:ERROR:gpu_memory_buffer_support_x11.cc(44)] dri3 extension not supported. cypress-cucumber-preprocessor resolved configuration { cypress-cucumber-preprocessor stepDefinitions: [ 'tests/cypress/integration/common/*/.js' ], cypress-cucumber-preprocessor filterSpecs: true, cypress-cucumber-preprocessor messages: { cypress-cucumber-preprocessor enabled: true, cypress-cucumber-preprocessor output: 'tests/cypress/cucumber-json/cucumber-messages.ndjson' cypress-cucumber-preprocessor }, cypress-cucumber-preprocessor json: { cypress-cucumber-preprocessor args: undefined, cypress-cucumber-preprocessor enabled: true, cypress-cucumber-preprocessor formatter: 'tests/cypress/cucumberJsonFormatter/cucumber-json-formatter', cypress-cucumber-preprocessor output: 'tests/cypress/cucumber-json/report.json' cypress-cucumber-preprocessor }, cypress-cucumber-preprocessor html: { cypress-cucumber-preprocessor enabled: true, cypress-cucumber-preprocessor output: 'tests/cypress/cucumber-json/cucumber-report.html' cypress-cucumber-preprocessor } cypress-cucumber-preprocessor } +0ms


  (Run Starting)
  │ Cypress:        11.2.0                                                                         │
  │ Browser:        Chrome 113 (headless)                                                          │
  │ Node Version:   v18.16.0 (/usr/local/bin/node)                                                 │
  │ Specs:          1 found (loginBase.feature)                                                    │
  │ Searched:       tests/cypress/integration/login/loginBase.feature                              │

  Running:  loginBase.feature                                                               (1 of 1)
Print browser name: chrome
  cypress-cucumber-preprocessor resolved configuration {
  cypress-cucumber-preprocessor   stepDefinitions: [ 'tests/cypress/integration/common/**/*.js' ],
  cypress-cucumber-preprocessor   filterSpecs: true,
  cypress-cucumber-preprocessor   messages: {
  cypress-cucumber-preprocessor     enabled: true,
  cypress-cucumber-preprocessor     output: 'tests/cypress/cucumber-json/cucumber-messages.ndjson'
  cypress-cucumber-preprocessor   },
  cypress-cucumber-preprocessor   json: {
  cypress-cucumber-preprocessor     args: undefined,
  cypress-cucumber-preprocessor     enabled: true,
  cypress-cucumber-preprocessor     formatter: 'tests/cypress/cucumberJsonFormatter/cucumber-json-formatter',
  cypress-cucumber-preprocessor     output: 'tests/cypress/cucumber-json/report.json'
  cypress-cucumber-preprocessor   },
  cypress-cucumber-preprocessor   html: {
  cypress-cucumber-preprocessor     enabled: true,
  cypress-cucumber-preprocessor     output: 'tests/cypress/cucumber-json/cucumber-report.html'
  cypress-cucumber-preprocessor   }
  cypress-cucumber-preprocessor } +2s
  cypress-cucumber-preprocessor resolving step definitions using template(s) [ 'tests/cypress/integration/common/**/*.js' ] +0ms
  cypress-cucumber-preprocessor replacing [filepath] with 'login/loginBase' +1ms
  cypress-cucumber-preprocessor replacing [filepart] with [ 'login/loginBase', 'login' ] +0ms
  cypress-cucumber-preprocessor for 'tests/cypress/integration/login/loginBase.feature' yielded patterns [ 'tests/cypress/integration/common/**/*.js' ] +0ms
  cypress-cucumber-preprocessor found step definitions [
  cypress-cucumber-preprocessor   'tests/cypress/integration/common/CompareArray.js',
  ....
  cypress-cucumber-preprocessor ] +6ms

  Login to base url
    1) Login to base url

  0 passing (21s)
  1 failing

  1) Login to base url
       Login to base url:
     AssertionError: Timed out retrying after 10000ms: Expected to find element: `.welcomeName`, but never found it.
      at Context.eval (https://**/__cypress/tests?p=tests/cypress/integration/login/loginBase.feature:18964:12)
      at Registry.runStepDefininition (https://**/__cypress/tests?p=tests/cypress/integration/login/loginBase.feature:9255:48)
      at Context.eval (https://**/__cypress/tests?p=tests/cypress/integration/login/loginBase.feature:10120:48)
  (Results)
  │ Tests:        1                                                                                │
  │ Passing:      0                                                                                │
  │ Failing:      1                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  1                                                                                │
  │ Video:        false                                                                            │
  │ Duration:     20 seconds                                                                       │
  │ Spec Ran:     loginBase.feature                                                                │

........
----------------------------------------------------------------------------------------------------
### Versions

* **Cypress version**: 11.2.0
* **Preprocessor version**: 14.0.0
* **Node version**:18.16.0

### Checklist

- [Y] I've read the [FAQ](https://github.com/badeball/cypress-cucumber-preprocessor/blob/master/docs/faq.md).
- [Y] I've read [instructions for logging issues](https://github.com/badeball/cypress-cucumber-preprocessor/blob/master/CONTRIBUTING.md#bug-reports).
- [Y] I'm not using `cypress-cucumber-preprocessor@4.3.1` (package name has changed and it is no longer the most recent version, see [#689](https://github.com/badeball/cypress-cucumber-preprocessor/issues/689)).
badeball commented 1 year ago

Hey, and thanks for reporting this issue. You need to provide a minimal, reproducible example issues that illustrates the issue.

badeball commented 1 year ago

It's glaringly obvious from your ticket, that you have not yourself gone through the process of trying to reproduce the issue using the information that you've provided me. Instead, you're just assuming you've provided me with everything that's relevant and you're leaving it up to me to test that assumption. This is a huge waste of my time, as almost everyone fails to provide the relevant information. This is why I'm asking everyone in the contributing guidelines, to provide me with a runable example. If it doesn't run, then you've clearly not tested it.

huiyangns commented 1 year ago

Hi badeball, what you said makes sense I will provide a runable example asap Thanks for reply

huiyangns commented 1 year ago

Hi badeball, I may find the cause of this issue In my cypress.config.js file, I use cypress-cloud to run test in parallel way. This plugin seems to intercept logs which should be printed in cucumber-messages.ndjson file. When I comment out cloudPlugin(on, config);, everything is good

.....
const { cloudPlugin } = require("cypress-cloud/plugin");
....
 e2e: {
 .....
    async setupNodeEvents(on, config) {
      await preprocessor.addCucumberPreprocessorPlugin(on, config);
      on(
        "file:preprocessor",
        createBundler({
          plugins: [createEsbuildPlugin.default(config)],
        })
      );

      cloudPlugin(on, config);
      return require('./tests/cypress/plugins/index.js')(on, config)
    },
  },
badeball commented 1 year ago

https://github.com/badeball/cypress-cucumber-preprocessor/blob/master/docs/event-handlers.md