Skip to content

Commit

Permalink
refactor: migrate to new japa
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 authored Feb 27, 2022
1 parent bb8cf13 commit fd59260
Show file tree
Hide file tree
Showing 13 changed files with 195 additions and 155 deletions.
7 changes: 7 additions & 0 deletions .bin/japaTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Assert } from '@japa/assert'

declare module '@japa/runner' {
interface TestContext {
assert: Assert
}
}
7 changes: 0 additions & 7 deletions .bin/test.js

This file was deleted.

37 changes: 37 additions & 0 deletions .bin/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { assert } from '@japa/assert'
import { specReporter } from '@japa/spec-reporter'
import { runFailedTests } from '@japa/run-failed-tests'
import { processCliArgs, configure, run } from '@japa/runner'

/*
|--------------------------------------------------------------------------
| Configure tests
|--------------------------------------------------------------------------
|
| The configure method accepts the configuration to configure the Japa
| tests runner.
|
| The first method call "processCliArgs" process the command line arguments
| and turns them into a config object. Using this method is not mandatory.
|
| Please consult japa.dev/runner-config for the config docs.
*/
configure({
...processCliArgs(process.argv.slice(2)),
...{
files: ['test/**/*.spec.ts'],
plugins: [assert(), runFailedTests()],
reporters: [specReporter()],
importer: (filePath: string) => import(filePath),
},
})

/*
|--------------------------------------------------------------------------
| Run tests
|--------------------------------------------------------------------------
|
| The following "run" method is required to execute all the tests.
|
*/
run()
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"scripts": {
"mrm": "mrm --preset=@adonisjs/mrm-preset",
"pretest": "npm run lint",
"test": "node .bin/test.js",
"clean": "del build",
"test": "node -r ts-node/register/transpile-only .bin/test.ts",
"clean": "del-cli build",
"copyfiles": "copyfiles \"templates/**/*.txt\" \"instructions.md\" build",
"compile": "npm run lint && npm run clean && tsc",
"build": "npm run compile && npm run copyfiles",
Expand All @@ -44,6 +44,10 @@
"@adonisjs/require-ts": "^2.0.10",
"@adonisjs/sink": "^5.2.2",
"@adonisjs/view": "^6.1.2",
"@japa/assert": "^1.2.3",
"@japa/run-failed-tests": "^1.0.3",
"@japa/runner": "^1.2.0",
"@japa/spec-reporter": "^1.1.7",
"@poppinss/dev-utils": "^2.0.2",
"@types/node": "^17.0.21",
"aws-sdk": "^2.1082.0",
Expand All @@ -58,7 +62,6 @@
"eslint-plugin-prettier": "^4.0.0",
"github-label-sync": "^2.0.2",
"husky": "^7.0.4",
"japa": "^4.0.0",
"luxon": "^2.3.1",
"mrm": "^3.0.10",
"np": "^7.6.0",
Expand Down
8 changes: 4 additions & 4 deletions test/base-mailer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/

import test from 'japa'
import { test } from '@japa/runner'
import { MessageContract, BaseMailer as BaseMailerContract } from '@ioc:Adonis/Addons/Mail'

import { Message } from '../src/Message'
Expand All @@ -18,11 +18,11 @@ import { BaseMailer as BaseMailerClass } from '../src/BaseMailer'
const BaseMailer = BaseMailerClass as unknown as typeof BaseMailerContract

test.group('BaseMailer', (group) => {
group.afterEach(async () => {
group.each.teardown(async () => {
await fs.cleanup()
})

test('send email using the mailer class', async (assert) => {
test('send email using the mailer class', async ({ assert }) => {
assert.plan(1)

const config = {
Expand Down Expand Up @@ -56,7 +56,7 @@ test.group('BaseMailer', (group) => {
await mailer.send()
})

test('use a custom mailer', async (assert) => {
test('use a custom mailer', async ({ assert }) => {
assert.plan(1)

const config = {
Expand Down
Loading

0 comments on commit fd59260

Please sign in to comment.