0

I am attempting to use a global beforeeach() algorithm defined in support/e2e to filter tests. This code works.

beforeEach(function () {

var testSuite = new Array();
testSuite = (Cypress.env('suites'));
if (!testSuite) {
    return;
}
const testName = Cypress.mocha.getRunner().test.fullTitle().toLowerCase();
let matches = testSuite.some((value) => {
    return (testName.includes(value))
});

if (!matches) {
    this.skip();
}
return;

})

However, when using in conjunction with cypress-failed-log, tests that are skipped because of the prior algorithm are failing with this error:

     TypeError: Cannot read properties of undefined (reading 'message')
Because this error occurred during a `after each` hook we are skipping all of the remaining tests.
  at Context.onFailed (webpack:///./node_modules/cypress-failed-log/src/index.js:136:0)

This is what my plug in looks like. It works independent of the sorting algorithm and fails with the same message even if I only leave just the failed:required line and remove the code that uses the message object.

    on('task', {
    failed: require('cypress-failed-log/src/failed')()
    ,
    log(message) {
        console.log(message)
        return null
    },
    table(message) {
        console.table(message)
        return null
    }
    
})
K.A.
  • 81
  • 1
  • 3
  • I actually figured this out. I added this above this.currentTest.err= { message: "skipped" }; "this.skips()" – K.A. Oct 17 '22 at 20:18

0 Answers0