diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0610c55..582175c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ on: jobs: test: - uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3 + uses: fastify/workflows/.github/workflows/plugins-ci.yml@v4.1.0 with: lint: true license-check: true diff --git a/.taprc b/.taprc index 017ea1c..3a5e97b 100644 --- a/.taprc +++ b/.taprc @@ -1,7 +1,4 @@ -ts: false -jsx: false -flow: false -coverage: true - files: - test/**/*.js +plugin: + - "!@tapjs/typescript" diff --git a/package.json b/package.json index 59cefc6..0f93ba7 100644 --- a/package.json +++ b/package.json @@ -27,12 +27,13 @@ }, "homepage": "https://github.com/fastify/fastify-plugin#readme", "devDependencies": { - "@fastify/type-provider-typebox": "^4.0.0", - "@types/node": "^20.1.0", - "fastify": "^4.0.1", + "@fastify/pre-commit": "^2.1.0", + "@fastify/type-provider-typebox": "^5.0.0-pre.fv5.1", + "@types/node": "^20.11.20", + "fastify": "^5.0.0-alpha.2", "proxyquire": "^2.1.3", - "standard": "^17.0.0", - "tap": "^16.0.1", + "standard": "^17.1.0", + "tap": "^18.7.0", "tsd": "^0.31.0" } } diff --git a/test/test.js b/test/test.js index 2895513..ac52ee3 100644 --- a/test/test.js +++ b/test/test.js @@ -6,6 +6,8 @@ const test = t.test const fp = require('../plugin') const Fastify = require('fastify') +const pkg = require('../package.json') + test('fastify-plugin is a function', t => { t.plan(1) t.type(fp, 'function') @@ -206,12 +208,12 @@ test('should check fastify dependency graph - plugin', t => { const fastify = Fastify() fastify.register(fp((fastify, opts, next) => next(), { - fastify: '4.x', + fastify: '5.x', name: 'plugin1-name' })) fastify.register(fp((fastify, opts, next) => next(), { - fastify: '4.x', + fastify: '5.x', name: 'test', dependencies: ['plugin1-name', 'plugin2-name'] })) @@ -226,12 +228,12 @@ test('should check fastify dependency graph - decorate', t => { const fastify = Fastify() fastify.decorate('plugin1', fp((fastify, opts, next) => next(), { - fastify: '4.x', + fastify: '5.x', name: 'plugin1-name' })) fastify.register(fp((fastify, opts, next) => next(), { - fastify: '4.x', + fastify: '5.x', name: 'test', decorators: { fastify: ['plugin1', 'plugin2'] } })) @@ -246,12 +248,12 @@ test('should check fastify dependency graph - decorateReply', t => { const fastify = Fastify() fastify.decorateReply('plugin1', fp((fastify, opts, next) => next(), { - fastify: '4.x', + fastify: '5.x', name: 'plugin1-name' })) fastify.register(fp((fastify, opts, next) => next(), { - fastify: '4.x', + fastify: '5.x', name: 'test', decorators: { reply: ['plugin1', 'plugin2'] } })) @@ -311,20 +313,24 @@ test('should check dependencies when encapsulated', t => { }) }) -test('should check version when encapsulated', t => { - t.plan(1) - const fastify = Fastify() +test( + 'should check version when encapsulated', + { skip: /\d-.+/.test(pkg.devDependencies.fastify) }, + t => { + t.plan(1) + const fastify = Fastify() - fastify.register(fp((fastify, opts, next) => next(), { - name: 'test', - fastify: '<=2.10.0', - encapsulate: true - })) + fastify.register(fp((fastify, opts, next) => next(), { + name: 'test', + fastify: '<=2.10.0', + encapsulate: true + })) - fastify.ready(err => { - t.match(err.message, /fastify-plugin: test - expected '<=2.10.0' fastify version, '\d.\d+.\d+' is installed/) - }) -}) + fastify.ready(err => { + t.match(err.message, /fastify-plugin: test - expected '<=2.10.0' fastify version, '\d.\d+.\d+' is installed/) + }) + } +) test('should check decorators when encapsulated', t => { t.plan(1) @@ -333,7 +339,7 @@ test('should check decorators when encapsulated', t => { fastify.decorate('plugin1', 'foo') fastify.register(fp((fastify, opts, next) => next(), { - fastify: '4.x', + fastify: '5.x', name: 'test', encapsulate: true, decorators: { fastify: ['plugin1', 'plugin2'] } @@ -352,14 +358,14 @@ test('plugin name when encapsulated', async t => { }) fastify.register(fp(getFn('hello'), { - fastify: '4.x', + fastify: '5.x', name: 'hello', encapsulate: true })) fastify.register(function plugin (fastify, opts, next) { fastify.register(fp(getFn('deep'), { - fastify: '4.x', + fastify: '5.x', name: 'deep', encapsulate: true })) @@ -368,25 +374,25 @@ test('plugin name when encapsulated', async t => { t.equal(fastify.pluginName, 'deep-deep', 'should be deep-deep') fastify.register(fp(getFn('deep-deep-deep'), { - fastify: '4.x', + fastify: '5.x', name: 'deep-deep-deep', encapsulate: true })) fastify.register(fp(getFn('deep-deep -> not-encapsulated-2'), { - fastify: '4.x', + fastify: '5.x', name: 'not-encapsulated-2' })) next() }, { - fastify: '4.x', + fastify: '5.x', name: 'deep-deep', encapsulate: true })) fastify.register(fp(getFn('plugin -> not-encapsulated'), { - fastify: '4.x', + fastify: '5.x', name: 'not-encapsulated' }))