Skip to content

Commit 291a81a

Browse files
committed
add basic test
1 parent 19ace8a commit 291a81a

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

bin/test.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
'use strict'
2+
3+
const { specReporter } = require('@japa/spec-reporter')
4+
const { runFailedTests } = require('@japa/run-failed-tests')
5+
const { processCliArgs, configure, run } = require('@japa/runner')
6+
7+
/*
8+
|--------------------------------------------------------------------------
9+
| Configure tests
10+
|--------------------------------------------------------------------------
11+
|
12+
| The configure method accepts the configuration to configure the Japa
13+
| tests runner.
14+
|
15+
| The first method call "processCliArgs" process the command line arguments
16+
| and turns them into a config object. Using this method is not mandatory.
17+
|
18+
| Please consult japa.dev/runner-config for the config docs.
19+
*/
20+
21+
const plugins = []
22+
23+
if (!process.env.CI) {
24+
plugins.push(runFailedTests())
25+
}
26+
27+
configure({
28+
...processCliArgs(process.argv.slice(2)),
29+
...{
30+
plugins,
31+
timeout: 2000,
32+
files: ['test/**/*.js'],
33+
reporters: [specReporter()],
34+
importer: (filePath) => require(filePath),
35+
filters: {
36+
// files: ['mongodb-service-provider.js']
37+
}
38+
}
39+
})
40+
41+
/*
42+
|--------------------------------------------------------------------------
43+
| Run tests
44+
|--------------------------------------------------------------------------
45+
|
46+
| The following "run" method is required to execute all the tests.
47+
|
48+
*/
49+
run()

test/basic.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict'
2+
3+
const config = require('../dist')
4+
const { expect } = require('expect')
5+
const { test } = require('@japa/runner')
6+
const { isObject } = require('./helpers/utils')
7+
8+
test('test basic properties of config', () => {
9+
// expect(isObject(config.env)).toBe(true)
10+
expect(isObject(config.rules)).toBe(true)
11+
// expect(isObject(config.globals)).toBe(true)
12+
expect(isObject(config.parserOptions)).toBe(true)
13+
})

test/helpers/utils.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict'
2+
3+
module.exports.isObject = function isObject (obj) {
4+
return typeof obj === 'object' && obj !== null
5+
}

0 commit comments

Comments
 (0)