diff --git a/bin/test.js b/bin/test.js new file mode 100644 index 0000000..b828d70 --- /dev/null +++ b/bin/test.js @@ -0,0 +1,49 @@ +'use strict' + +const { specReporter } = require('@japa/spec-reporter') +const { runFailedTests } = require('@japa/run-failed-tests') +const { processCliArgs, configure, run } = require('@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. +*/ + +const plugins = [] + +if (!process.env.CI) { + plugins.push(runFailedTests()) +} + +configure({ + ...processCliArgs(process.argv.slice(2)), + ...{ + plugins, + timeout: 2000, + files: ['test/**/*.js'], + reporters: [specReporter()], + importer: (filePath) => require(filePath), + filters: { + // files: ['mongodb-service-provider.js'] + } + } +}) + +/* +|-------------------------------------------------------------------------- +| Run tests +|-------------------------------------------------------------------------- +| +| The following "run" method is required to execute all the tests. +| +*/ +run() diff --git a/test/basic.js b/test/basic.js new file mode 100644 index 0000000..65f75bc --- /dev/null +++ b/test/basic.js @@ -0,0 +1,13 @@ +'use strict' + +const config = require('../dist') +const { expect } = require('expect') +const { test } = require('@japa/runner') +const { isObject } = require('./helpers/utils') + +test('test basic properties of config', () => { + // expect(isObject(config.env)).toBe(true) + expect(isObject(config.rules)).toBe(true) + // expect(isObject(config.globals)).toBe(true) + expect(isObject(config.parserOptions)).toBe(true) +}) diff --git a/test/helpers/utils.js b/test/helpers/utils.js new file mode 100644 index 0000000..e92f1a8 --- /dev/null +++ b/test/helpers/utils.js @@ -0,0 +1,5 @@ +'use strict' + +module.exports.isObject = function isObject (obj) { + return typeof obj === 'object' && obj !== null +}