Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created March 27, 2023 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacs/0f6d49fd7264625c9db0e2414ff90072 to your computer and use it in GitHub Desktop.
Save isaacs/0f6d49fd7264625c9db0e2414ff90072 to your computer and use it in GitHub Desktop.
import { Test } from '@tapjs/test'
import assert from 'node:assert'
const t = new Test({})
t.stream.pipe(process.stdout)
t.before(() => {
assert.equal(t.t, t, 'self ref is equal in before()')
})
t.after(() => {
assert.equal(t.t, t, 'self-ref is equal in after()')
})
t.equal(t.t, t, 'returned test equals self-reference t property')
t.test('child test', function someName(tt) {
tt.equal(1, 2)
return tt.end()
})
t.end()
/*
TAP version 14
ok 1 - returned test equals self-reference t property
# Subtest: child test
not ok 1 - should be equal
---
diff: |
--- expected
+++ actual
@@ -1,1 +1,1 @@
-2
+1
compare: ===
at:
line: 18
column: 6
file: t.ts
function: Test.someName
stack: |
Test.someName (t.ts:18:6)
Object.<anonymous> (t.ts:17:3)
source: |
t.test('child test', function someName(tt) {
tt.equal(1, 2)
-----^
return tt.end()
})
...
1..1
# failed 1 test
not ok 2 - child test # time=12862ms
---
stack: |
Object.<anonymous> (t.ts:17:3)
context: null
...
1..2
# failed 1 of 2 tests
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment