Skip to content

Commit 2bb443c

Browse files
authored
feat(test-optimization): create final_status tag on test event for mocha (#7844)
1 parent e5c5a9b commit 2bb443c

13 files changed

Lines changed: 749 additions & 4 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict'
2+
3+
const assert = require('assert')
4+
5+
describe('mocha-flaky', () => {
6+
it('can retry failed tests', () => {
7+
assert.strictEqual(1 + 2, 4)
8+
})
9+
})
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict'
2+
3+
const assert = require('assert')
4+
let counter = 0
5+
6+
describe('mocha-flaky', () => {
7+
it('can retry flaky tests', () => {
8+
assert.strictEqual(++counter, 2)
9+
})
10+
11+
it('will not retry passed tests', () => {
12+
assert.ok(true)
13+
})
14+
})
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict'
2+
3+
const assert = require('assert')
4+
5+
describe('disable tests with hooks', () => {
6+
beforeEach(() => {
7+
// setup
8+
})
9+
10+
afterEach(() => {
11+
// teardown
12+
})
13+
14+
it('can disable a test with hooks', () => {
15+
assert.strictEqual(1 + 2, 4) // intentionally fails
16+
})
17+
})
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict'
2+
3+
const assert = require('assert')
4+
5+
describe('mocha-hooks flaky-fails', () => {
6+
beforeEach(() => {
7+
// setup
8+
})
9+
10+
afterEach(() => {
11+
// teardown
12+
})
13+
14+
it('can retry failed tests', () => {
15+
assert.strictEqual(1 + 2, 4) // intentionally fails
16+
})
17+
})
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict'
2+
3+
const assert = require('assert')
4+
let counter = 0
5+
6+
describe('mocha-hooks flaky-passes', () => {
7+
beforeEach(() => {
8+
// setup
9+
})
10+
11+
afterEach(() => {
12+
// teardown
13+
})
14+
15+
it('can retry flaky tests', () => {
16+
assert.strictEqual(++counter, 2)
17+
})
18+
19+
it('will not retry passed tests', () => {
20+
assert.ok(true)
21+
})
22+
})
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict'
2+
3+
const assert = require('assert')
4+
5+
describe('mocha-hooks known', () => {
6+
beforeEach(() => {
7+
// setup
8+
})
9+
10+
afterEach(() => {
11+
// teardown
12+
})
13+
14+
it('can report known tests', () => {
15+
assert.ok(true)
16+
})
17+
})
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict'
2+
3+
const assert = require('assert')
4+
5+
describe('mocha-hooks new', () => {
6+
beforeEach(() => {
7+
// setup
8+
})
9+
10+
afterEach(() => {
11+
// teardown
12+
})
13+
14+
it('can report new tests', () => {
15+
assert.ok(true)
16+
})
17+
})
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict'
2+
3+
describe('quarantine tests with failing afterEach', () => {
4+
afterEach(() => {
5+
throw new Error('afterEach hook failed')
6+
})
7+
8+
it('can quarantine a test whose afterEach hook fails', () => {
9+
// test passes, but the afterEach will throw
10+
})
11+
})
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict'
2+
3+
const assert = require('assert')
4+
5+
describe('quarantine tests with hooks', () => {
6+
beforeEach(() => {
7+
// setup
8+
})
9+
10+
afterEach(() => {
11+
// teardown
12+
})
13+
14+
it('can quarantine a test with hooks', () => {
15+
assert.strictEqual(1 + 2, 4) // intentionally fails
16+
})
17+
18+
it('can pass normally with hooks', () => {
19+
assert.strictEqual(1 + 2, 3)
20+
})
21+
})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict'
2+
3+
describe('mocha-skips', () => {
4+
it.skip('can report skipped tests', () => {})
5+
})

0 commit comments

Comments
 (0)