diff --git a/.bin/test.js b/.bin/test.js deleted file mode 100644 index e20c2dd9..00000000 --- a/.bin/test.js +++ /dev/null @@ -1,7 +0,0 @@ -require('@adonisjs/require-ts/build/register') - -const { configure } = require('japa') - -configure({ - files: ['test/**/*.spec.ts'], -}) diff --git a/bin/japaTypes.ts b/bin/japaTypes.ts new file mode 100644 index 00000000..d42cac68 --- /dev/null +++ b/bin/japaTypes.ts @@ -0,0 +1,7 @@ +import { Assert } from '@japa/assert' + +declare module '@japa/runner' { + interface TestContext { + assert: Assert + } +} diff --git a/bin/test.ts b/bin/test.ts new file mode 100644 index 00000000..5aba7cef --- /dev/null +++ b/bin/test.ts @@ -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() diff --git a/package.json b/package.json index 02ee6b3b..d01cf336 100644 --- a/package.json +++ b/package.json @@ -15,9 +15,9 @@ "scripts": { "mrm": "mrm --preset=@adonisjs/mrm-preset", "pretest": "npm run lint", - "test": "cross-env FORCE_COLOR=true node .bin/test.js", + "test": "cross-env FORCE_COLOR=true node -r @adonisjs/require-ts/build/register ./bin/test.ts", "lint": "eslint . --ext=.ts", - "clean": "del build", + "clean": "del-cli build", "compile": "npm run lint && npm run clean && tsc", "build": "npm run compile && node build/bin/index.js && copyfiles \"templates/**\" build", "commit": "git-cz", @@ -47,6 +47,10 @@ "@adonisjs/ace": "^11.2.3", "@adonisjs/core": "^5.7.4", "@adonisjs/mrm-preset": "^5.0.3", + "@japa/assert": "^1.3.4", + "@japa/run-failed-tests": "^1.0.7", + "@japa/runner": "^2.0.7", + "@japa/spec-reporter": "^1.1.12", "@poppinss/dev-utils": "^2.0.3", "@types/node": "^17.0.24", "commitizen": "^4.2.4", @@ -60,7 +64,6 @@ "eslint-plugin-prettier": "^4.0.0", "github-label-sync": "^2.2.0", "husky": "^7.0.4", - "japa": "^4.0.0", "mrm": "^4.0.0", "np": "^7.6.1", "prettier": "^2.6.2", diff --git a/test/compiler.spec.ts b/test/compiler.spec.ts index 09cf49ad..95d8c6e3 100644 --- a/test/compiler.spec.ts +++ b/test/compiler.spec.ts @@ -7,7 +7,7 @@ * file that was distributed with this source code. */ -import test from 'japa' +import { test } from '@japa/runner' import execa from 'execa' import { join } from 'path' import { Filesystem } from '@poppinss/dev-utils' @@ -20,19 +20,19 @@ const ui = instantiate(true) const fs = new Filesystem(join(__dirname, '__app')) test.group('Compiler', (group) => { - group.before(() => { + group.setup(() => { ui.logger.useRenderer(ui.testingRenderer) }) - group.afterEach(() => { + group.each.teardown(() => { ui.testingRenderer.logs = [] }) - group.afterEach(async () => { + group.each.teardown(async () => { await fs.cleanup() }) - test('build source files', async (assert) => { + test('build source files', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -96,7 +96,7 @@ test.group('Compiler', (group) => { assert.isFalse(require(join(fs.basePath, 'build', '.adonisrc.json')).typescript) }).timeout(0) - test('build source files with explicit outDir', async (assert) => { + test('build source files with explicit outDir', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -158,7 +158,7 @@ test.group('Compiler', (group) => { ]) }).timeout(0) - test('build source files with explicit rootDir', async (assert) => { + test('build source files with explicit rootDir', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -221,7 +221,7 @@ test.group('Compiler', (group) => { ]) }).timeout(0) - test('build source files to nested outDir', async (assert) => { + test('build source files to nested outDir', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -284,7 +284,7 @@ test.group('Compiler', (group) => { ]) }).timeout(0) - test('do not build when config has errors', async (assert) => { + test('do not build when config has errors', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -333,7 +333,7 @@ test.group('Compiler', (group) => { ]) }).timeout(0) - test('catch and report typescript errors', async (assert) => { + test('catch and report typescript errors', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -401,7 +401,7 @@ test.group('Compiler', (group) => { ]) }).timeout(0) - test('do not continue on error', async (assert) => { + test('do not continue on error', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -469,7 +469,7 @@ test.group('Compiler', (group) => { ]) }).timeout(0) - test('do not emit when noEmitOnError is true', async (assert) => { + test('do not emit when noEmitOnError is true', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -530,7 +530,7 @@ test.group('Compiler', (group) => { ]) }).timeout(0) - test('build for production should copy package files to build folder', async (assert) => { + test('build for production should copy package files to build folder', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -618,7 +618,9 @@ test.group('Compiler', (group) => { assert.isTrue(hasPackageLock) }).timeout(0) - test('gracefully log error when ace file finishes with non-zero exit code', async (assert) => { + test('gracefully log error when ace file finishes with non-zero exit code', async ({ + assert, + }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -689,7 +691,7 @@ test.group('Compiler', (group) => { assert.isFalse(require(join(fs.basePath, 'build', '.adonisrc.json')).typescript) }).timeout(0) - test('ignore error when any of the meta file is missing', async (assert) => { + test('ignore error when any of the meta file is missing', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -744,7 +746,7 @@ test.group('Compiler', (group) => { assert.isFalse(require(join(fs.basePath, 'build', '.adonisrc.json')).typescript) }).timeout(0) - test('build should support custom tsconfig file', async (assert) => { + test('build should support custom tsconfig file', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -795,7 +797,7 @@ test.group('Compiler', (group) => { assert.deepEqual(hasFiles, [true, true, false]) }).timeout(0) - test('typecheck and report typescript errors', async (assert) => { + test('typecheck and report typescript errors', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -848,7 +850,7 @@ test.group('Compiler', (group) => { ]) }).timeout(0) - test('complete successfully when typechecking has no errors', async (assert) => { + test('complete successfully when typechecking has no errors', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ diff --git a/test/configure-encore.spec.ts b/test/configure-encore.spec.ts index b858b202..ef2c6446 100644 --- a/test/configure-encore.spec.ts +++ b/test/configure-encore.spec.ts @@ -7,7 +7,7 @@ * file that was distributed with this source code. */ -import test from 'japa' +import { test } from '@japa/runner' import { join } from 'path' import { Kernel } from '@adonisjs/ace' import { Filesystem } from '@poppinss/dev-utils' @@ -18,34 +18,34 @@ import Invoke from '../commands/Invoke' const fs = new Filesystem(join(__dirname, '__app')) test.group('Configure Encore', (group) => { - group.afterEach(async () => { + group.each.teardown(async () => { await fs.cleanup() }) - test - .skipInCI('setup encore', async (assert) => { - await fs.add( - 'package.json', - JSON.stringify({ - name: 'sample_app', - }) - ) - - await fs.ensureRoot() - const app = new Application(fs.basePath, 'test', {}) - - const invoke = new Invoke(app, new Kernel(app).mockConsoleOutput()) - invoke.packages = ['encore'] - await invoke.run() - - const envFile = await fs.fsExtra.pathExists(join(fs.basePath, 'webpack.config.js')) - const envExampleFile = await fs.fsExtra.readFile( - join(fs.basePath, 'resources/js/app.js'), - 'utf-8' - ) - - assert.isTrue(envFile) - assert.equal(envExampleFile.trim(), '// app entrypoint') - }) + test('setup encore', async ({ assert }) => { + await fs.add( + 'package.json', + JSON.stringify({ + name: 'sample_app', + }) + ) + + await fs.ensureRoot() + const app = new Application(fs.basePath, 'test', {}) + + const invoke = new Invoke(app, new Kernel(app).mockConsoleOutput()) + invoke.packages = ['encore'] + await invoke.run() + + const envFile = await fs.fsExtra.pathExists(join(fs.basePath, 'webpack.config.js')) + const envExampleFile = await fs.fsExtra.readFile( + join(fs.basePath, 'resources/js/app.js'), + 'utf-8' + ) + + assert.isTrue(envFile) + assert.equal(envExampleFile.trim(), '// app entrypoint') + }) .timeout(0) + .skip(!!process.env.CI) }) diff --git a/test/configure-tests.spec.ts b/test/configure-tests.spec.ts index 165daa8b..e73b51eb 100644 --- a/test/configure-tests.spec.ts +++ b/test/configure-tests.spec.ts @@ -7,7 +7,7 @@ * file that was distributed with this source code. */ -import test from 'japa' +import { test } from '@japa/runner' import { join } from 'path' import { Kernel } from '@adonisjs/ace' import { Filesystem } from '@poppinss/dev-utils' @@ -18,32 +18,32 @@ import Invoke from '../commands/Invoke' const fs = new Filesystem(join(__dirname, '__app')) test.group('Configure Tests', (group) => { - group.afterEach(async () => { + group.each.teardown(async () => { await fs.cleanup() }) - test - .skipInCI('setup tests', async (assert) => { - await fs.add( - 'package.json', - JSON.stringify({ - name: 'sample_app', - }) - ) - - await fs.ensureRoot() - const app = new Application(fs.basePath, 'test', {}) - - const invoke = new Invoke(app, new Kernel(app).mockConsoleOutput()) - invoke.packages = ['tests'] - await invoke.run() - - assert.isTrue(await fs.fsExtra.pathExists(join(fs.basePath, 'test.ts'))) - assert.isTrue(await fs.fsExtra.pathExists(join(fs.basePath, 'tests/bootstrap.ts'))) - assert.isTrue( - await fs.fsExtra.pathExists(join(fs.basePath, 'tests/functional/hello_world.spec.ts')) - ) - assert.isTrue(await fs.fsExtra.pathExists(join(fs.basePath, 'contracts/tests.ts'))) - }) + test('setup tests', async ({ assert }) => { + await fs.add( + 'package.json', + JSON.stringify({ + name: 'sample_app', + }) + ) + + await fs.ensureRoot() + const app = new Application(fs.basePath, 'test', {}) + + const invoke = new Invoke(app, new Kernel(app).mockConsoleOutput()) + invoke.packages = ['tests'] + await invoke.run() + + assert.isTrue(await fs.fsExtra.pathExists(join(fs.basePath, 'test.ts'))) + assert.isTrue(await fs.fsExtra.pathExists(join(fs.basePath, 'tests/bootstrap.ts'))) + assert.isTrue( + await fs.fsExtra.pathExists(join(fs.basePath, 'tests/functional/hello_world.spec.ts')) + ) + assert.isTrue(await fs.fsExtra.pathExists(join(fs.basePath, 'contracts/tests.ts'))) + }) .timeout(0) + .skip(!!process.env.CI) }) diff --git a/test/env-parser.spec.ts b/test/env-parser.spec.ts index 0288edcd..02efc636 100644 --- a/test/env-parser.spec.ts +++ b/test/env-parser.spec.ts @@ -7,7 +7,7 @@ * file that was distributed with this source code. */ -import test from 'japa' +import { test } from '@japa/runner' import { join } from 'path' import { Filesystem } from '@poppinss/dev-utils' @@ -16,7 +16,7 @@ import { EnvParser } from '../src/EnvParser' const fs = new Filesystem(join(__dirname, '__app')) test.group('EnvParser', (group) => { - group.afterEach(async () => { + group.each.teardown(async () => { await fs.cleanup() }) @@ -25,7 +25,7 @@ test.group('EnvParser', (group) => { await envParser.parse(fs.basePath) }) - test('get value for a key defined inside .env file', async (assert) => { + test('get value for a key defined inside .env file', async ({ assert }) => { await fs.add('.env', 'PORT=3333') const envParser = new EnvParser() @@ -33,7 +33,7 @@ test.group('EnvParser', (group) => { assert.equal(envParser.get('PORT'), '3333') }) - test('get an object of values for defined keys', async (assert) => { + test('get an object of values for defined keys', async ({ assert }) => { await fs.add('.env', ['PORT=3333', 'TZ=Asia/Calcutta'].join('\n')) const envParser = new EnvParser() diff --git a/test/invoke-command.spec.ts b/test/invoke-command.spec.ts index 2d3e9c91..1098d527 100644 --- a/test/invoke-command.spec.ts +++ b/test/invoke-command.spec.ts @@ -7,7 +7,7 @@ * file that was distributed with this source code. */ -import test from 'japa' +import { test } from '@japa/runner' import { join } from 'path' import { Kernel } from '@adonisjs/ace' import { Filesystem } from '@poppinss/dev-utils' @@ -18,11 +18,11 @@ import Invoke from '../commands/Invoke' const fs = new Filesystem(join(__dirname, '__app')) test.group('Invoke', (group) => { - group.afterEach(async () => { + group.each.teardown(async () => { await fs.cleanup() }) - test('execute instructions defined in package.json file', async (assert) => { + test('execute instructions defined in package.json file', async ({ assert }) => { await fs.add( 'node_modules/@adonisjs/sample/package.json', JSON.stringify({ diff --git a/test/make-command.spec.ts b/test/make-command.spec.ts index dd438d4d..f2abf7f3 100644 --- a/test/make-command.spec.ts +++ b/test/make-command.spec.ts @@ -7,7 +7,7 @@ * file that was distributed with this source code. */ -import test from 'japa' +import { test } from '@japa/runner' import { join } from 'path' import { Kernel } from '@adonisjs/ace' import { readJSONSync } from 'fs-extra' @@ -21,19 +21,19 @@ const fs = new Filesystem(join(__dirname, '__app')) const templates = new Filesystem(join(__dirname, '..', 'templates')) test.group('Make Command', (group) => { - group.before(() => { + group.setup(() => { process.env.ADONIS_ACE_CWD = fs.basePath }) - group.after(() => { + group.teardown(() => { delete process.env.ADONIS_ACE_CWD }) - group.afterEach(async () => { + group.each.teardown(async () => { await fs.cleanup() }) - test('make a command inside the default directory', async (assert) => { + test('make a command inside the default directory', async ({ assert }) => { await fs.add('.adonisrc.json', JSON.stringify({})) const rcContents = readJSONSync(join(fs.basePath, '.adonisrc.json')) @@ -56,7 +56,7 @@ test.group('Make Command', (group) => { ) }) - test('make a command inside a custom directory', async (assert) => { + test('make a command inside a custom directory', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -86,7 +86,7 @@ test.group('Make Command', (group) => { ) }) - test('convert camelcase command path to colon seperated name', async (assert) => { + test('convert camelcase command path to colon seperated name', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ diff --git a/test/make-controller.spec.ts b/test/make-controller.spec.ts index ab55bd10..f6297ba2 100644 --- a/test/make-controller.spec.ts +++ b/test/make-controller.spec.ts @@ -7,7 +7,7 @@ * file that was distributed with this source code. */ -import test from 'japa' +import { test } from '@japa/runner' import { join } from 'path' import { readJSONSync } from 'fs-extra' import { Kernel } from '@adonisjs/ace' @@ -21,19 +21,19 @@ const fs = new Filesystem(join(__dirname, '__app')) const templates = new Filesystem(join(__dirname, '..', 'templates')) test.group('Make Controller', (group) => { - group.before(() => { + group.setup(() => { process.env.ADONIS_ACE_CWD = fs.basePath }) - group.after(() => { + group.teardown(() => { delete process.env.ADONIS_ACE_CWD }) - group.afterEach(async () => { + group.each.teardown(async () => { await fs.cleanup() }) - test('make a controller inside the default directory', async (assert) => { + test('make a controller inside the default directory', async ({ assert }) => { await fs.add('.adonisrc.json', JSON.stringify({})) const rcContents = readJSONSync(join(fs.basePath, '.adonisrc.json')) @@ -51,7 +51,7 @@ test.group('Make Controller', (group) => { ) }) - test('make a resourceful controller inside the default directory', async (assert) => { + test('make a resourceful controller inside the default directory', async ({ assert }) => { await fs.add('.adonisrc.json', JSON.stringify({})) const rcContents = readJSONSync(join(fs.basePath, '.adonisrc.json')) @@ -70,7 +70,7 @@ test.group('Make Controller', (group) => { ) }) - test('make a controller inside a custom directory', async (assert) => { + test('make a controller inside a custom directory', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ diff --git a/test/make-exception.spec.ts b/test/make-exception.spec.ts index bf63acad..eb96bd40 100644 --- a/test/make-exception.spec.ts +++ b/test/make-exception.spec.ts @@ -7,7 +7,7 @@ * file that was distributed with this source code. */ -import test from 'japa' +import { test } from '@japa/runner' import { join } from 'path' import { readJSONSync } from 'fs-extra' import { Kernel } from '@adonisjs/ace' @@ -21,19 +21,19 @@ const fs = new Filesystem(join(__dirname, '__app')) const templates = new Filesystem(join(__dirname, '..', 'templates')) test.group('Make Exception', (group) => { - group.before(() => { + group.setup(() => { process.env.ADONIS_ACE_CWD = fs.basePath }) - group.after(() => { + group.teardown(() => { delete process.env.ADONIS_ACE_CWD }) - group.afterEach(async () => { + group.each.teardown(async () => { await fs.cleanup() }) - test('make an exception class inside the default directory', async (assert) => { + test('make an exception class inside the default directory', async ({ assert }) => { await fs.add('.adonisrc.json', JSON.stringify({})) const rcContents = readJSONSync(join(fs.basePath, '.adonisrc.json')) @@ -53,7 +53,7 @@ test.group('Make Exception', (group) => { ) }) - test('make a self-handled exception class inside the default directory', async (assert) => { + test('make a self-handled exception class inside the default directory', async ({ assert }) => { await fs.add('.adonisrc.json', JSON.stringify({})) const rcContents = readJSONSync(join(fs.basePath, '.adonisrc.json')) @@ -74,7 +74,7 @@ test.group('Make Exception', (group) => { ) }) - test('make an exception class inside a custom directory', async (assert) => { + test('make an exception class inside a custom directory', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ diff --git a/test/make-listener.spec.ts b/test/make-listener.spec.ts index 10102b4a..97e33c7c 100644 --- a/test/make-listener.spec.ts +++ b/test/make-listener.spec.ts @@ -7,7 +7,7 @@ * file that was distributed with this source code. */ -import test from 'japa' +import { test } from '@japa/runner' import { join } from 'path' import { readJSONSync } from 'fs-extra' import { Kernel } from '@adonisjs/ace' @@ -21,19 +21,19 @@ const fs = new Filesystem(join(__dirname, '__app')) const templates = new Filesystem(join(__dirname, '..', 'templates')) test.group('Make Listener', (group) => { - group.before(() => { + group.setup(() => { process.env.ADONIS_ACE_CWD = fs.basePath }) - group.after(() => { + group.teardown(() => { delete process.env.ADONIS_ACE_CWD }) - group.afterEach(async () => { + group.each.teardown(async () => { await fs.cleanup() }) - test('make a listener inside the default directory', async (assert) => { + test('make a listener inside the default directory', async ({ assert }) => { await fs.add('.adonisrc.json', JSON.stringify({})) const rcContents = readJSONSync(join(fs.basePath, '.adonisrc.json')) @@ -51,7 +51,7 @@ test.group('Make Listener', (group) => { ) }) - test('make a listener inside a custom directory', async (assert) => { + test('make a listener inside a custom directory', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ diff --git a/test/make-middleware.spec.ts b/test/make-middleware.spec.ts index f65b1231..826eca2e 100644 --- a/test/make-middleware.spec.ts +++ b/test/make-middleware.spec.ts @@ -7,7 +7,7 @@ * file that was distributed with this source code. */ -import test from 'japa' +import { test } from '@japa/runner' import { join } from 'path' import { readJSONSync } from 'fs-extra' import { Kernel } from '@adonisjs/ace' @@ -21,19 +21,19 @@ const fs = new Filesystem(join(__dirname, '__app')) const templates = new Filesystem(join(__dirname, '..', 'templates')) test.group('Make Middleware', (group) => { - group.before(() => { + group.setup(() => { process.env.ADONIS_ACE_CWD = fs.basePath }) - group.after(() => { + group.teardown(() => { delete process.env.ADONIS_ACE_CWD }) - group.afterEach(async () => { + group.each.teardown(async () => { await fs.cleanup() }) - test('make a middleware inside the default directory', async (assert) => { + test('make a middleware inside the default directory', async ({ assert }) => { await fs.add('.adonisrc.json', JSON.stringify({})) const rcContents = readJSONSync(join(fs.basePath, '.adonisrc.json')) diff --git a/test/make-preloaded-file.spec.ts b/test/make-preloaded-file.spec.ts index 59ad8528..b4eb0018 100644 --- a/test/make-preloaded-file.spec.ts +++ b/test/make-preloaded-file.spec.ts @@ -7,7 +7,7 @@ * file that was distributed with this source code. */ -import test from 'japa' +import { test } from '@japa/runner' import { join } from 'path' import { readJSONSync } from 'fs-extra' import { Kernel } from '@adonisjs/ace' @@ -21,19 +21,19 @@ const fs = new Filesystem(join(__dirname, '__app')) const templates = new Filesystem(join(__dirname, '..', 'templates')) test.group('Make Preloaded File', (group) => { - group.before(() => { + group.setup(() => { process.env.ADONIS_ACE_CWD = fs.basePath }) - group.after(() => { + group.teardown(() => { delete process.env.ADONIS_ACE_CWD }) - group.afterEach(async () => { + group.each.teardown(async () => { await fs.cleanup() }) - test('make a preload file inside the start directory', async (assert) => { + test('make a preload file inside the start directory', async ({ assert }) => { await fs.add('.adonisrc.json', JSON.stringify({})) const rcContents = readJSONSync(join(fs.basePath, '.adonisrc.json')) @@ -59,7 +59,7 @@ test.group('Make Preloaded File', (group) => { }) }) - test('make a preload file inside custom directory', async (assert) => { + test('make a preload file inside custom directory', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -93,7 +93,7 @@ test.group('Make Preloaded File', (group) => { }) }) - test('select environment as repl', async (assert) => { + test('select environment as repl', async ({ assert }) => { await fs.add('.adonisrc.json', JSON.stringify({})) const rcContents = readJSONSync(join(fs.basePath, '.adonisrc.json')) @@ -119,7 +119,7 @@ test.group('Make Preloaded File', (group) => { }) }) - test('prompt for environment when not explicitly defined', async (assert) => { + test('prompt for environment when not explicitly defined', async ({ assert }) => { await fs.add('.adonisrc.json', JSON.stringify({})) const rcContents = readJSONSync(join(fs.basePath, '.adonisrc.json')) diff --git a/test/make-provider.spec.ts b/test/make-provider.spec.ts index fec5b21b..d9792099 100644 --- a/test/make-provider.spec.ts +++ b/test/make-provider.spec.ts @@ -7,7 +7,7 @@ * file that was distributed with this source code. */ -import test from 'japa' +import { test } from '@japa/runner' import { join } from 'path' import { readJSONSync } from 'fs-extra' import { Kernel } from '@adonisjs/ace' @@ -21,19 +21,19 @@ const fs = new Filesystem(join(__dirname, '__app')) const templates = new Filesystem(join(__dirname, '..', 'templates')) test.group('Make Provider', (group) => { - group.before(() => { + group.setup(() => { process.env.ADONIS_ACE_CWD = fs.basePath }) - group.after(() => { + group.teardown(() => { delete process.env.ADONIS_ACE_CWD }) - group.afterEach(async () => { + group.each.teardown(async () => { await fs.cleanup() }) - test('make a provider inside the default directory', async (assert) => { + test('make a provider inside the default directory', async ({ assert }) => { await fs.add('.adonisrc.json', JSON.stringify({})) const rcContents = readJSONSync(join(fs.basePath, '.adonisrc.json')) @@ -56,7 +56,7 @@ test.group('Make Provider', (group) => { }) }) - test('make a provider inside a custom directory', async (assert) => { + test('make a provider inside a custom directory', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -89,7 +89,7 @@ test.group('Make Provider', (group) => { }) }) - test('setup correct path when nested provider is created', async (assert) => { + test('setup correct path when nested provider is created', async ({ assert }) => { await fs.add('.adonisrc.json', JSON.stringify({})) const rcContents = readJSONSync(join(fs.basePath, '.adonisrc.json')) @@ -112,7 +112,7 @@ test.group('Make Provider', (group) => { }) }) - test('make ace provider', async (assert) => { + test('make ace provider', async ({ assert }) => { await fs.add('.adonisrc.json', JSON.stringify({})) const rcContents = readJSONSync(join(fs.basePath, '.adonisrc.json')) diff --git a/test/make-test.spec.ts b/test/make-test.spec.ts index 4a397e8e..ac021160 100644 --- a/test/make-test.spec.ts +++ b/test/make-test.spec.ts @@ -7,7 +7,7 @@ * file that was distributed with this source code. */ -import test from 'japa' +import { test } from '@japa/runner' import { join } from 'path' import { readJSONSync } from 'fs-extra' import { Kernel } from '@adonisjs/ace' @@ -21,19 +21,19 @@ const fs = new Filesystem(join(__dirname, '__app')) const templates = new Filesystem(join(__dirname, '..', 'templates')) test.group('Make Test', (group) => { - group.before(() => { + group.setup(() => { process.env.ADONIS_ACE_CWD = fs.basePath }) - group.after(() => { + group.teardown(() => { delete process.env.ADONIS_ACE_CWD }) - group.afterEach(async () => { + group.each.teardown(async () => { await fs.cleanup() }) - test('make a test inside the suite directory', async (assert) => { + test('make a test inside the suite directory', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -59,7 +59,7 @@ test.group('Make Test', (group) => { ) }) - test('make a test inside nested directory', async (assert) => { + test('make a test inside nested directory', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -85,7 +85,7 @@ test.group('Make Test', (group) => { ) }) - test('return error when suite is not registered', async (assert) => { + test('return error when suite is not registered', async ({ assert }) => { await fs.add('.adonisrc.json', JSON.stringify({})) const rcContents = readJSONSync(join(fs.basePath, '.adonisrc.json')) diff --git a/test/make-validator.spec.ts b/test/make-validator.spec.ts index 0e5fe383..c431de17 100644 --- a/test/make-validator.spec.ts +++ b/test/make-validator.spec.ts @@ -7,7 +7,7 @@ * file that was distributed with this source code. */ -import test from 'japa' +import { test } from '@japa/runner' import { join } from 'path' import { readJSONSync } from 'fs-extra' import { Kernel } from '@adonisjs/ace' @@ -21,19 +21,19 @@ const fs = new Filesystem(join(__dirname, '__app')) const templates = new Filesystem(join(__dirname, '..', 'templates')) test.group('Make Validator', (group) => { - group.before(() => { + group.setup(() => { process.env.ADONIS_ACE_CWD = fs.basePath }) - group.after(() => { + group.teardown(() => { delete process.env.ADONIS_ACE_CWD }) - group.afterEach(async () => { + group.each.teardown(async () => { await fs.cleanup() }) - test('make a model inside the default directory', async (assert) => { + test('make a model inside the default directory', async ({ assert }) => { await fs.add('.adonisrc.json', JSON.stringify({})) const rcContents = readJSONSync(join(fs.basePath, '.adonisrc.json')) @@ -53,7 +53,7 @@ test.group('Make Validator', (group) => { ) }) - test('make a validator inside a custom directory', async (assert) => { + test('make a validator inside a custom directory', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ diff --git a/test/make-view.spec.ts b/test/make-view.spec.ts index ee1e5230..27f6f750 100644 --- a/test/make-view.spec.ts +++ b/test/make-view.spec.ts @@ -7,7 +7,7 @@ * file that was distributed with this source code. */ -import test from 'japa' +import { test } from '@japa/runner' import { join } from 'path' import { readJSONSync } from 'fs-extra' import { Kernel } from '@adonisjs/ace' @@ -19,19 +19,19 @@ import MakeView from '../commands/Make/View' const fs = new Filesystem(join(__dirname, '__app')) test.group('Make Command', (group) => { - group.before(() => { + group.setup(() => { process.env.ADONIS_ACE_CWD = fs.basePath }) - group.after(() => { + group.teardown(() => { delete process.env.ADONIS_ACE_CWD }) - group.afterEach(async () => { + group.each.teardown(async () => { await fs.cleanup() }) - test('make an empty view inside the default directory', async (assert) => { + test('make an empty view inside the default directory', async ({ assert }) => { await fs.add('.adonisrc.json', JSON.stringify({})) const rcContents = readJSONSync(join(fs.basePath, '.adonisrc.json')) @@ -45,7 +45,7 @@ test.group('Make Command', (group) => { assert.deepEqual(welcomeView.trim(), '') }) - test('make a view inside a nested directory', async (assert) => { + test('make a view inside a nested directory', async ({ assert }) => { await fs.add('.adonisrc.json', JSON.stringify({})) const rcContents = readJSONSync(join(fs.basePath, '.adonisrc.json')) @@ -59,7 +59,7 @@ test.group('Make Command', (group) => { assert.deepEqual(welcomeView.trim(), '') }) - test('make an empty view inside custom directory', async (assert) => { + test('make an empty view inside custom directory', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ diff --git a/test/rc-file.spec.ts b/test/rc-file.spec.ts index 30daa90a..dd86ae45 100644 --- a/test/rc-file.spec.ts +++ b/test/rc-file.spec.ts @@ -7,7 +7,7 @@ * file that was distributed with this source code. */ -import test from 'japa' +import { test } from '@japa/runner' import { join } from 'path' import { Filesystem } from '@poppinss/dev-utils' @@ -16,11 +16,11 @@ import { RcFile } from '../src/RcFile' const fs = new Filesystem(join(__dirname, '__app')) test.group('RcFile', (group) => { - group.afterEach(async () => { + group.each.teardown(async () => { await fs.cleanup() }) - test('get an array of meta file patterns from the rcfile', async (assert) => { + test('get an array of meta file patterns from the rcfile', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -32,7 +32,7 @@ test.group('RcFile', (group) => { assert.deepEqual(rcFile.getMetaFilesGlob(), ['.env', 'public/**/*.(css|js)', 'ace']) }) - test('get info about a meta file', async (assert) => { + test('get info about a meta file', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -63,7 +63,7 @@ test.group('RcFile', (group) => { }) }) - test('match relative paths against meta files', async (assert) => { + test('match relative paths against meta files', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -78,7 +78,7 @@ test.group('RcFile', (group) => { assert.isFalse(rcFile.isMetaFile('public/script.sass')) }) - test('match relative paths against reloadServer meta files', async (assert) => { + test('match relative paths against reloadServer meta files', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -92,7 +92,7 @@ test.group('RcFile', (group) => { assert.isFalse(rcFile.isRestartServerFile('.env')) }) - test('filter .adonisrc.json file from files globs array', async (assert) => { + test('filter .adonisrc.json file from files globs array', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -108,7 +108,7 @@ test.group('RcFile', (group) => { assert.deepEqual(rcFile.getMetaFilesGlob(), ['.env', 'public/**/*.(css|js)', 'ace']) }) - test('filter ace file from files globs array', async (assert) => { + test('filter ace file from files globs array', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -120,7 +120,7 @@ test.group('RcFile', (group) => { assert.deepEqual(rcFile.getMetaFilesGlob(), ['.env', 'public/**/*.(css|js)', 'ace']) }) - test('get metadata for files', async (assert) => { + test('get metadata for files', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -162,7 +162,7 @@ test.group('RcFile', (group) => { }) }) - test('match sub paths to the defined command path', async (assert) => { + test('match sub paths to the defined command path', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -175,7 +175,7 @@ test.group('RcFile', (group) => { assert.isTrue(rcFile.isCommandsPath('commands/foo.ts')) }) - test('match actual path to the defined command path', async (assert) => { + test('match actual path to the defined command path', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -188,7 +188,7 @@ test.group('RcFile', (group) => { assert.isTrue(rcFile.isCommandsPath('commands.ts')) }) - test('do not work when commands refer to path outside the project root', async (assert) => { + test('do not work when commands refer to path outside the project root', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -202,7 +202,7 @@ test.group('RcFile', (group) => { assert.isFalse(rcFile.isCommandsPath('commands/foo.ts')) }) - test('do not work when commands refer to a package', async (assert) => { + test('do not work when commands refer to a package', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({ @@ -216,7 +216,7 @@ test.group('RcFile', (group) => { assert.isFalse(rcFile.isCommandsPath('@adonisjs/foo/foo.ts')) }) - test('read file from the disk by-passing the cache', async (assert) => { + test('read file from the disk by-passing the cache', async ({ assert }) => { await fs.add( '.adonisrc.json', JSON.stringify({