Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: adding esbuild bundler to CI pipeline (#3616)
* test: adding esbuild bundler test * test: adding esbuild to package ci * test: updating bundle test * test: check message labels on bundlers
- Loading branch information
Showing
8 changed files
with
85 additions
and
12 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict' | ||
|
||
const t = require('tap') | ||
const test = t.test | ||
const fastifySuccess = require('./dist/success') | ||
const fastifyFailPlugin = require('./dist/failPlugin') | ||
|
||
test('Bundled package should work', (t) => { | ||
t.plan(4) | ||
fastifySuccess.ready((err) => { | ||
t.error(err) | ||
fastifySuccess.inject( | ||
{ | ||
method: 'GET', | ||
url: '/' | ||
}, | ||
(error, res) => { | ||
t.error(error) | ||
t.equal(res.statusCode, 200) | ||
t.same(res.json(), { hello: 'world' }) | ||
} | ||
) | ||
}) | ||
}) | ||
|
||
test('Bundled package should not work with bad plugin version', (t) => { | ||
t.plan(1) | ||
fastifyFailPlugin.ready((err) => { | ||
t.match(err.message, /expected '9.x' fastify version/i) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"version": "0.0.1", | ||
"scripts": { | ||
"bundle": "esbuild success=src/index.js failPlugin=src/fail-plugin-version.js --bundle --outdir=dist --platform=node", | ||
"test": "npm run bundle && node bundler-test.js" | ||
}, | ||
"devDependencies": { | ||
"esbuild": "^0.14.11" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const fp = require('fastify-plugin') | ||
const fastify = require('../../../../')() | ||
|
||
fastify.get('/', function (request, reply) { | ||
reply.send({ hello: 'world' }) | ||
}) | ||
|
||
fastify.register(fp((instance, opts, done) => { | ||
done() | ||
}, { fastify: '9.x' })) | ||
|
||
module.exports = fastify |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const fastify = require('../../../../')() | ||
// Declare a route | ||
fastify.get('/', function (request, reply) { | ||
reply.send({ hello: 'world' }) | ||
}) | ||
|
||
module.exports = fastify |
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