Skip to content

Commit

Permalink
chore: upgrade japa to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Jul 4, 2023
1 parent d011ae8 commit 9c4fcc0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 34 deletions.
7 changes: 0 additions & 7 deletions bin/japa_types.ts

This file was deleted.

24 changes: 4 additions & 20 deletions bin/test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { assert } from '@japa/assert'
import { pathToFileURL } from 'node:url'
import { expectTypeOf } from '@japa/expect-type'
import { specReporter } from '@japa/spec-reporter'
import { runFailedTests } from '@japa/run-failed-tests'
import { processCliArgs, configure, run } from '@japa/runner'
import { processCLIArgs, configure, run } from '@japa/runner'

/*
|--------------------------------------------------------------------------
Expand All @@ -18,23 +15,10 @@ import { processCliArgs, configure, run } from '@japa/runner'
|
| Please consult japa.dev/runner-config for the config docs.
*/
processCLIArgs(process.argv.splice(2))
configure({
...processCliArgs(process.argv.slice(2)),
...{
files: ['tests/**/*.spec.ts'],
plugins: [
assert(),
runFailedTests(),
expectTypeOf(),
(_, __, { TestContext }) => {
TestContext.macro('sleep', function (time: number) {
return new Promise((resolve) => setTimeout(resolve, time))
})
},
],
reporters: [specReporter()],
importer: (filePath: string) => import(pathToFileURL(filePath).href),
},
files: ['tests/**/*.spec.ts'],
plugins: [assert(), expectTypeOf()],
})

/*
Expand Down
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@
"@commitlint/cli": "^17.6.6",
"@commitlint/config-conventional": "^17.6.6",
"@fastify/middie": "^8.3.0",
"@japa/assert": "^1.4.1",
"@japa/expect-type": "^1.0.3",
"@japa/run-failed-tests": "^1.1.1",
"@japa/runner": "^2.5.1",
"@japa/spec-reporter": "^1.3.3",
"@japa/assert": "^2.0.0-1",
"@japa/expect-type": "^2.0.0-0",
"@japa/runner": "^3.0.0-3",
"@swc/core": "^1.3.67",
"@types/accepts": "^1.3.5",
"@types/content-disposition": "^0.5.5",
Expand Down
5 changes: 3 additions & 2 deletions tests/cookies/serializer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import { test } from '@japa/runner'
import { setTimeout } from 'node:timers/promises'
import { base64, MessageBuilder } from '@poppinss/utils'
import { EncryptionFactory } from '@adonisjs/encryption/factories'

Expand Down Expand Up @@ -81,13 +82,13 @@ test.group('Cookie | serialize', () => {
assert.equal(options, `HttpOnly`)
})

test('invoke expires callback when defined as a function', async ({ assert, sleep }) => {
test('invoke expires callback when defined as a function', async ({ assert }) => {
const config = { expires: () => new Date() }

const serializer = new CookieSerializer(encryption)
const serialized = serializer.encode('username', 'virk', config)

await sleep(1000)
await setTimeout(1000)
const serialized1 = serializer.encode('username', 'virk', config)
assert.notEqual(serialized, serialized1)
})
Expand Down

0 comments on commit 9c4fcc0

Please sign in to comment.