I am using mocha to run tests, I want to skip the test programatically. I came across this.skip(). I want to skip the test based on condition but I am seeing error 'TypeError: this.skip is not a function'
Also I am not this.skip(), here this refers to which object?
This is my spec file
test.spec.js
const expect = require('chai').expect;
const Mochaexport = require('../cypress/support/mochaExport');
let mochaExp = new Mochaexport();
describe('mocha test', function() {
it('runs mocha test', function() {
mochaExp.skipTest("2020");
expect(true).to.equal(true);
})
})
mochaExport.js
const { expect } = require("chai");
module.exports = function() {
this.skipTest = function(Year) {
if(Year == "2020") {
this.skip();
} else {
expect(Year).to.equal(2021);
}
}
}