BackstopJS icon indicating copy to clipboard operation
BackstopJS copied to clipboard

Travis build passes, but a test fails

Open hamtaai opened this issue 7 years ago • 7 comments

E.g, for build https://travis-ci.org/garris/BackstopJS/jobs/504019959 the result is 14 passing (198ms) 3 pending 1 failing

But travis is green.

The failing test: should work without an option param (test/core/util/makeConfig_spec.js)

Randomly checking older builds, this has been there for several months.

hamtaai avatar Mar 09 '19 14:03 hamtaai

Still happens today with the last commit (v4.3.3) : https://travis-ci.org/garris/BackstopJS/jobs/608273740

But now we have:

  12 passing (218ms)
  3 pending
  3 failing

  1) core report
       generates a json report and a default browser report when config.report specifies json:

     TypeError: Cannot read property 'config' of undefined
      at writeBrowserReport (core/command/report.js:28:26)
      at writeReport (core/command/report.js:21:17)
      at /home/travis/build/garris/BackstopJS/core/command/report.js:179:14
      at <anonymous>

  2) make config
       should return the default config correctly:

      AssertionError [ERR_ASSERTION]: { args: {},
  backstop: '/home/travis/build/garris/BackstopJS',
  perf: {},
  bitmaps_reference: '/home/travis/build/garris/Back deepStrictEqual { args: {},
  asyncCompareLimit: undefined,
  backstop: '/home/travis/build/garris/BackstopJS',
  backstopVersion: '4.3.3',
  bi
      + expected - actual
         "comparePath": "/home/travis/build/garris/BackstopJS/compare/output"
         "compareReportURL": "/home/travis/build/garris/BackstopJS/test/core/util/backstop_data/html_report/index.html"
         "debug": false
         "defaultMisMatchThreshold": 0.1
      -  "dockerCommandTemplate": [undefined]
         "engine": [null]
         "engine_scripts": "/home/travis/build/garris/BackstopJS/test/core/util/backstop_data/engine_scripts"
         "engine_scripts_default": "/home/travis/build/garris/BackstopJS/capture/engine_scripts"
         "html_report": "/home/travis/build/garris/BackstopJS/test/core/util/backstop_data/html_report"
      
      at Context.<anonymous> (test/core/util/makeConfig_it_spec.js:65:12)

  3) make config
       should work without an option param:

      AssertionError [ERR_ASSERTION]: {} === {}
      + expected - actual
      at Context.<anonymous> (test/core/util/makeConfig_spec.js:12:12)

ledenis avatar Nov 12 '19 16:11 ledenis

Thanks for the update. Looks like a bug -- we should absolutely this.

garris avatar Nov 12 '19 20:11 garris

Found the cause of the bug, the tests exited with exit code 0. If we comment out this line in https://github.com/garris/BackstopJS/blob/master/cli/index.js#L47

    // process.exit(code || exitCode);

and make a test to fail (since now tests are fixed). Now the tests fail as intended with exit code 1.

$ npm run unit-test
...
  17 passing (223ms)
  3 pending
  1 failing

  1) the cli usage
       should print usage hints correctly:

      AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

  assert(false)

      + expected - actual

      -false
      +true
      
      at Context.<anonymous> (test/cli/usage_spec.js:8:5)



npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] unit-test: `mocha --reporter spec --recursive 'test/**/*_spec.js'`
npm ERR! Exit status 1

Not sure why we did process.exit(code || exitCode); or how to fix this.

Also, the related test is https://github.com/garris/BackstopJS/blob/master/test/cli/index_spec.js

Workaround : skip this test?

ledenis avatar Nov 17 '19 10:11 ledenis

@ledenis Wow. I don't remember what was going on when this test was created but this line looks maybe a little early. It should probably be called after index.js runs. https://github.com/garris/BackstopJS/blob/master/test/cli/index_spec.js#L17

I wonder if process.exit(code || exitCode); was a required hack because done() was being called too early? Really not sure.

I am ok with changing this stuff as long as we can explain what is happening.

Please let me know what you think. Cheers!

garris avatar Nov 18 '19 08:11 garris

I am not sure why we did this process.exit hack, so for now I think we should fix the test first. I will try to do it when I have time.

I suggest for short term to just it.skip the test now to fix the CI?

ledenis avatar Nov 18 '19 20:11 ledenis

Yes. Please just comment the line and add a note back to this thread. It doesn't look like it will break anything else -- so long as the other tests are passing. Thank you!

garris avatar Nov 18 '19 21:11 garris

What do you think about this PR https://github.com/garris/BackstopJS/pull/1125 ? @garris
I found there was another issue https://github.com/garris/BackstopJS/issues/750 similar to this, so the refactor might prevent these problems.

ledenis avatar Dec 03 '19 18:12 ledenis