Skip to content

Commit 0a0cab3

Browse files
committed
fix: do not evaluate assertions for regression tests
1 parent 41d4d11 commit 0a0cab3

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ export function assert(_options?: PluginConfig): PluginFn {
2626
return function () {
2727
TestContext.getter('assert', () => new Assert(), true)
2828
Test.executed(function (test: Test<any>, hasError) {
29+
/**
30+
* Do not evaluate assertions counts for regression tests.
31+
*/
32+
if (test.options.isFailing) {
33+
return
34+
}
35+
2936
if (!hasError) {
3037
test.context?.assert.assertions.validate()
3138
}

tests/plugin.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,34 @@ test.describe('Plugin', () => {
127127
testInstance.exec()
128128
testInstance1.exec()
129129
})
130+
131+
test('do not validate assertions when test is marked as a regression test', (_, done) => {
132+
let testsCount = 0
133+
const emitter = new Emitter()
134+
const refiner = new Refiner()
135+
const getContext = (t: Test<any>) => new TestContext(t)
136+
137+
const testInstance = new Test('test 1', getContext, emitter, refiner)
138+
testInstance
139+
.run(async (ctx) => {
140+
ctx['assert'].plan(2)
141+
ctx['assert'].equal(false, true)
142+
ctx['assert'].equal(true, true)
143+
})
144+
.fails()
145+
146+
emitter.on('test:end', (payload) => {
147+
testsCount++
148+
try {
149+
chaiAssert.isTrue(payload.isFailing)
150+
chaiAssert.isFalse(payload.hasError)
151+
chaiAssert.lengthOf(payload.errors, 0)
152+
done()
153+
} catch (error) {
154+
done(error)
155+
}
156+
})
157+
158+
testInstance.exec()
159+
})
130160
})

0 commit comments

Comments
 (0)