Aktueller Stand

This commit is contained in:
2026-01-22 19:05:45 +01:00
parent 85dee61a4d
commit e280e4eadb
1967 changed files with 397327 additions and 74093 deletions

View File

@@ -1,10 +1,10 @@
import { errorCodes } from '../../fastify.js'
import t from 'tap'
import { test } from 'node:test'
t.test('errorCodes in ESM', async t => {
test('errorCodes in ESM', async t => {
// test a custom fastify error using errorCodes with ESM
const customError = errorCodes.FST_ERR_VALIDATION('custom error message')
t.ok(typeof customError !== 'undefined')
t.ok(customError instanceof errorCodes.FST_ERR_VALIDATION)
t.equal(customError.message, 'custom error message')
t.assert.ok(typeof customError !== 'undefined')
t.assert.ok(customError instanceof errorCodes.FST_ERR_VALIDATION)
t.assert.strictEqual(customError.message, 'custom error message')
})

View File

@@ -1,7 +1,7 @@
import t from 'tap'
import { test } from 'node:test'
import Fastify from '../../fastify.js'
t.test('esm support', async t => {
test('esm support', async t => {
const fastify = Fastify()
fastify.register(import('./plugin.mjs'), { foo: 'bar' })
@@ -9,5 +9,5 @@ t.test('esm support', async t => {
await fastify.ready()
t.equal(fastify.foo, 'bar')
t.assert.strictEqual(fastify.foo, 'bar')
})

View File

@@ -1,18 +1,8 @@
'use strict'
const t = require('tap')
const semver = require('semver')
if (semver.lt(process.versions.node, '14.13.0')) {
t.skip('Skip named exports because Node version < 14.13.0')
} else {
// Node v8 throw a `SyntaxError: Unexpected token import`
// even if this branch is never touch in the code,
// by using `eval` we can avoid this issue.
// eslint-disable-next-line
new Function('module', 'return import(module)')('./named-exports.mjs').catch((err) => {
import('./named-exports.mjs')
.catch(err => {
process.nextTick(() => {
throw err
})
})
}

View File

@@ -1,8 +1,8 @@
import t from 'tap'
import { test } from 'node:test'
import { fastify } from '../../fastify.js'
// This test is executed in index.test.js
t.test('named exports support', async t => {
test('named exports support', async t => {
const app = fastify()
app.register(import('./plugin.mjs'), { foo: 'bar' })
@@ -10,5 +10,5 @@ t.test('named exports support', async t => {
await app.ready()
t.equal(app.foo, 'bar')
t.assert.strictEqual(app.foo, 'bar')
})

View File

@@ -1,8 +1,8 @@
// Imported in both index.test.js & esm.test.mjs
import t from 'tap'
import { strictEqual } from 'node:assert'
async function other (fastify, opts) {
t.equal(fastify.foo, 'bar')
strictEqual(fastify.foo, 'bar')
}
export default other