Accueil / javascript / 1-js / 03-code-quality / 05-testing-mocha / beforeafter.view / test.js
test.js
describe("test", function() {
// Mocha usually waits for the tests for 2 seconds before considering them wrong
this.timeout(200000); // With this code we increase this - in this case to 200,000 milliseconds
// This is because of the "alert" function, because if you delay pressing the "OK" button the tests will not pass!
before(() => alert("Testing started – before all tests"));
after(() => alert("Testing finished – after all tests"));
beforeEach(() => alert("Before a test – enter a test"));
afterEach(() => alert("After a test – exit a test"));
it('test 1', () => alert(1));
it('test 2', () => alert(2));
});