ember-backstop icon indicating copy to clipboard operation
ember-backstop copied to clipboard

Using ember-backstop in a CI pipeline

Open shibulijack-fd opened this issue 5 years ago • 9 comments

The documentation says:

You will need the backstop-remote service running for visual tests. In a seperate window run... ember backstop-remote

While it's feasible in local development environment, how does one go about achieving the same results in a CI like travis or Github Actions?

shibulijack-fd avatar Jan 29 '20 04:01 shibulijack-fd

Simply start the service prior to running tests. E.g. ember backstop-remote & ember test

garris avatar Jan 29 '20 06:01 garris

Simply start the service prior to running tests. E.g. ember backstop-remote & ember test

This works with ember backstop-stop in posttest hook, but in case of a failure, the process never exits and the CI builds timeout.

More importantly, how do we address this: https://github.com/garris/BackstopJS#using-docker-for-testing-across-different-environments

shibulijack-fd avatar Jan 30 '20 18:01 shibulijack-fd

Maybe we can work start-server-and-test into the doc somewhere.

ming-codes avatar Jun 22 '21 23:06 ming-codes

@ming-codes Happy to add a link or a example callout in the docs if you have a gist or a project template or an article that describes how this integration can work.

garris avatar Jun 23 '21 12:06 garris

Just this one liner in scripts should work.

// package.json
{
  "scripts": {
    ...
    "test": "ember test",
    "ci": "start-server-and-test 'ember backstop-remote' http://localhost:3000/version test"
    ...
  },
  "devDependencies": {
    ...
    "start-server-and-test": "^1.12.5"
    ...
  }
}

start-server-and-test takes a series of serve and resource pairs and then a final test command to run the test. Here's the breakdown of the script above.

start-server-and-test \
  'ember backstop-remote' \          # start backstop server
  http://localhost:3000/version \    # ping this endpoint to make sure server successfully started
  test                               # run the test!

We can even insert the above as part of the default blueprint

ming-codes avatar Jun 23 '21 17:06 ming-codes

Does this address the hang-forever issue?

garris avatar Jun 24 '21 02:06 garris

Should be. The command kills the server regardless the status of the test.

ming-codes avatar Jun 24 '21 04:06 ming-codes

Mildly related, how would you go about storing/approving changes? I setup my CircleCI pipeline and I'm getting this:

BackstopJS found differences. See: http://localhost:7357/backstop/backstop_data/html_report/

I see that the bitmap references are stored in ember-backstop/backstop_data/bitmaps_reference so why isn't the test picking them up in the CI pipeline?

these are my versions for things

ember-backstop 1.5.0
ember-cli: 3.25.3
node: 14.16.0

Sticksword avatar Sep 06 '21 18:09 Sticksword

Update: I learned that things were working fine, it just so happens that the Chrome version Circle CI was using is off by 1.5% and my test threshold was set to 0.1 by default

Main lesson is that Chrome can behave differently based on which image you use and how you install Chrome, resulting in slightly different screen captures.

Sticksword avatar Sep 07 '21 09:09 Sticksword