-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: migrate to node test runner (#1129)
* refactor(examples): switch to node test runner * refactor(deck): update the testing example * ci: add a test node 21 runner * ci: do not automerge on node version test * style(code): autofix and import order * refactor(tests): switch to assert/strict * chore(step-14): remove resolution error for node:assert * style(code): empty lines * ci(node): remove node * docs: use `assert/strict` in the slide dec instead * fix(tests): pass glob for node to infer * fix(tests): disable typechecking for tests
- Loading branch information
1 parent
125a356
commit d09d3e2
Showing
70 changed files
with
4,803 additions
and
8,493 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,46 @@ | ||
import t from 'tap' | ||
|
||
const { test } = t | ||
import { test } from 'node:test' | ||
import assert from 'node:assert/strict' | ||
|
||
import buildServer from '../index.js' | ||
|
||
test('POST /login', async t => { | ||
t.test('returns 400 with an invalid post payload', async t => { | ||
const fastify = buildServer() | ||
|
||
const res = await fastify.inject({ | ||
url: '/login', | ||
method: 'POST', | ||
body: { | ||
name: 'alice', | ||
passcode: 'alice', | ||
}, | ||
}) | ||
|
||
t.equal(res.statusCode, 400) | ||
}) | ||
|
||
t.test('returns the data with valid post payload', async t => { | ||
const fastify = buildServer() | ||
|
||
const res = await fastify.inject({ | ||
url: '/login', | ||
method: 'POST', | ||
body: { | ||
await t.test( | ||
'returns 400 with an invalid post payload', | ||
async () => { | ||
const fastify = buildServer() | ||
|
||
const res = await fastify.inject({ | ||
url: '/login', | ||
method: 'POST', | ||
body: { | ||
name: 'alice', | ||
passcode: 'alice', | ||
}, | ||
}) | ||
|
||
assert.equal(res.statusCode, 400) | ||
}, | ||
) | ||
|
||
await t.test( | ||
'returns the data with valid post payload', | ||
async () => { | ||
const fastify = buildServer() | ||
|
||
const res = await fastify.inject({ | ||
url: '/login', | ||
method: 'POST', | ||
body: { | ||
username: 'alice', | ||
password: 'alice', | ||
}, | ||
}) | ||
|
||
assert.equal(res.statusCode, 200) | ||
assert.deepEqual(res.json(), { | ||
username: 'alice', | ||
password: 'alice', | ||
}, | ||
}) | ||
|
||
t.equal(res.statusCode, 200) | ||
t.same(res.json(), { | ||
username: 'alice', | ||
password: 'alice', | ||
}) | ||
}) | ||
}) | ||
}, | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,46 @@ | ||
import t from 'tap' | ||
|
||
const { test } = t | ||
import { test } from 'node:test' | ||
import assert from 'node:assert/strict' | ||
|
||
import buildServer from '../index.js' | ||
|
||
test('POST /login', async t => { | ||
t.test('returns 400 with an invalid post payload', async t => { | ||
const fastify = buildServer() | ||
|
||
const res = await fastify.inject({ | ||
url: '/login', | ||
method: 'POST', | ||
body: { | ||
name: 'alice', | ||
passcode: 'alice', | ||
}, | ||
}) | ||
|
||
t.equal(res.statusCode, 400) | ||
}) | ||
|
||
t.test('returns the data with valid post payload', async t => { | ||
const fastify = buildServer() | ||
|
||
const res = await fastify.inject({ | ||
url: '/login', | ||
method: 'POST', | ||
body: { | ||
await t.test( | ||
'returns 400 with an invalid post payload', | ||
async () => { | ||
const fastify = buildServer() | ||
|
||
const res = await fastify.inject({ | ||
url: '/login', | ||
method: 'POST', | ||
body: { | ||
name: 'alice', | ||
passcode: 'alice', | ||
}, | ||
}) | ||
|
||
assert.equal(res.statusCode, 400) | ||
}, | ||
) | ||
|
||
await t.test( | ||
'returns the data with valid post payload', | ||
async () => { | ||
const fastify = buildServer() | ||
|
||
const res = await fastify.inject({ | ||
url: '/login', | ||
method: 'POST', | ||
body: { | ||
username: 'alice', | ||
password: 'alice', | ||
}, | ||
}) | ||
|
||
assert.equal(res.statusCode, 200) | ||
assert.deepEqual(res.json(), { | ||
username: 'alice', | ||
password: 'alice', | ||
}, | ||
}) | ||
|
||
t.equal(res.statusCode, 200) | ||
t.same(res.json(), { | ||
username: 'alice', | ||
password: 'alice', | ||
}) | ||
}) | ||
}) | ||
}, | ||
) | ||
}) |
Oops, something went wrong.