0

I'm trying to create a visual regression framework using mocha, with the visual diff done using backstopjs.

I've got a small first test running, but when I intentionally fail the test, I'd like the mocha framework to acknowledge the failure and report this. As It stands, when running the mocha framework everything goes as I'd expect, but the mocha report still shows as a pass, even though backstopjs is reporting the failure.

Here is my sample test

const assert = require('chai').assert
const backstop = require('backstopjs')


describe('Navigation To Google', () => {
  it('and take a screenshot', () => {

    backstop('test', {config: './backstop.json'})
     .then(() => {
        console.log('backstop test')
     }).catch((e) => {
         //If fails catch error here
         console.log(`The error is ${e}`)
     })

     // I assume I need to handle the assertion here

  });
})

My github and the code can be viewed here: https://github.com/Kpizzle/PupperDif

Kpizzle
  • 410
  • 4
  • 18

1 Answers1

0

Solve my question, I'm pretty new to Javascript and still have to wrap my head around the async nature of it.

I added an async await to the code. See new code.

const assert = require("chai").assert;
const backstop = require("backstopjs");

describe("Navigation To Google", () => {
it("and take a screenshot", async () => {
await backstop("test", { config: "./backstopScenarios/backstop.google.json" })
  .then(() => {
    console.log("backstop test");
  })
  .catch(e => {
    //If fails catch error here
    assert.ifError(e);
  });
 });
});
Kpizzle
  • 410
  • 4
  • 18