diff --git a/ava.config.js b/ava.config.js index 97c0b8b..9624f9b 100644 --- a/ava.config.js +++ b/ava.config.js @@ -5,4 +5,14 @@ export default { timeout: '1m', faileFast: true, extensions: ['ts', 'js'], + nodeArguments: [ + "--loader=ts-node/esm", + "--experimental-specifier-resolution=node" + ], + extensions: { + "ts": "module" + }, + nonSemVerExperiments: { + "configurableModuleFormat": true + }, } \ No newline at end of file diff --git a/package.json b/package.json index 848f3df..fd3a1fc 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "test": "npm run test:unit && npm run test:e2e", "start": "cross-env NODE_ENV=production node --loader ts-node/esm ./src/index.ts", "dev": "env-cmd -f .env.development nodemon --watch \"src/**/*.ts\" --exec \"node --loader ts-node/esm --unhandled-rejections=strict --trace-warnings\" src/index.ts", - "test:unit": "ava", + "test:unit": "TS_NODE_PROJECT='./tsconfig-spec.json' ava", "test:e2e": "exit 0" }, "keywords": [ diff --git a/src/config/__test__/validate.test.js b/src/config/__test__/validate.test.js deleted file mode 100644 index e3d92dd..0000000 --- a/src/config/__test__/validate.test.js +++ /dev/null @@ -1,7 +0,0 @@ -import test from 'ava'; - -const fn = () => 'foo'; - -test('mock test for first running', t => { - t.is(fn(), 'foo'); -}); \ No newline at end of file diff --git a/src/config/__test__/validate.test.ts b/src/config/__test__/validate.test.ts new file mode 100644 index 0000000..37a4a05 --- /dev/null +++ b/src/config/__test__/validate.test.ts @@ -0,0 +1,29 @@ +import { validateConfig } from '../validate.js' +import test from 'ava' +import { RawConfig } from '../types.js' + +const config: RawConfig = { + port: 'mock-port', + appName: 'mini-test', + baseRedirectUrl: 'http://mock.com', + url: { + matchPattern: 'mock-patter', + lifetime: '120', + }, + storage: { + driverName: 'InMemory', + relationalDriverConfig: { + client: 'mock-client', + connection: { + host: 'local-host', + user: 'snir-hamair', + password: 'admin1234', + database: 'mock-db', + }, + }, + }, +} + +test('validate config - happy flow [configuration set propely]', (t) => { + t.is(validateConfig(config), true) +}) diff --git a/tsconfig-spec.json b/tsconfig-spec.json new file mode 100644 index 0000000..3e4cc67 --- /dev/null +++ b/tsconfig-spec.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "ESNext", + } + } diff --git a/tsconfig.json b/tsconfig.json index 40ba65b..4266e06 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,6 +15,6 @@ "experimentalDecorators": true, "pretty": true, "noFallthroughCasesInSwitch": true, - "noImplicitReturns": true + "noImplicitReturns": true, }, }