web-api.test.js — fastify Source File
Architecture documentation for web-api.test.js, a javascript file in the fastify codebase.
Entity Profile
Source Code
'use strict'
const { test } = require('node:test')
const Fastify = require('../fastify')
const fs = require('node:fs')
const { Readable } = require('node:stream')
const { fetch: undiciFetch } = require('undici')
const http = require('node:http')
const { setTimeout: sleep } = require('node:timers/promises')
test('should response with a ReadableStream', async (t) => {
t.plan(2)
const fastify = Fastify()
fastify.get('/', function (request, reply) {
const stream = fs.createReadStream(__filename)
reply.code(200).send(Readable.toWeb(stream))
})
const {
statusCode,
body
} = await fastify.inject({ method: 'GET', path: '/' })
const expected = await fs.promises.readFile(__filename)
t.assert.strictEqual(statusCode, 200)
t.assert.strictEqual(expected.toString(), body.toString())
})
test('should response with a Response', async (t) => {
t.plan(3)
const fastify = Fastify()
fastify.get('/', function (request, reply) {
const stream = fs.createReadStream(__filename)
reply.send(new Response(Readable.toWeb(stream), {
status: 200,
headers: {
hello: 'world'
}
}))
})
const {
statusCode,
headers,
body
} = await fastify.inject({ method: 'GET', path: '/' })
const expected = await fs.promises.readFile(__filename)
t.assert.strictEqual(statusCode, 200)
t.assert.strictEqual(expected.toString(), body.toString())
t.assert.strictEqual(headers.hello, 'world')
})
test('should response with a Response 204', async (t) => {
// ... (557 more lines)
Source
Frequently Asked Questions
What does web-api.test.js do?
web-api.test.js is a source file in the fastify codebase, written in javascript.
Where is web-api.test.js in the architecture?
web-api.test.js is located at test/web-api.test.js (directory: test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free