Skip to content

Commit

Permalink
chore: run test in docker
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Apr 12, 2022
1 parent 48f02a9 commit ee64e4b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bin/licia.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const { contain, parseArgs } = require('licia');
const options = parseArgs(process.argv.slice(2), {
names: {
browser: 'boolean',
docker: 'boolean',
silent: 'boolean',
all: 'boolean',
sauce: 'boolean',
Expand All @@ -14,6 +15,7 @@ const options = parseArgs(process.argv.slice(2), {
},
shorthands: {
browser: 'b',
docker: 'd',
silent: 's',
all: 'a',
release: 'r'
Expand Down
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
test:
image: node:12.22.12
volumes:
- ./:/licia
working_dir: /licia
environment:
- MOD_NAME
command: ./node_modules/.bin/mocha .licia/test/${MOD_NAME}
11 changes: 10 additions & 1 deletion lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,16 @@ async function runMod(modName) {
if (options.all) return;

await runScripts(testScripts.before);
if (options.type === 'mocha') {
if (options.docker) {
process.env.MOD_NAME = modName;
await runScript('docker-compose', [
'run',
'-e',
`MOD_NAME=${modName}`,
'--rm',
'test'
]);
} else if (options.type === 'mocha') {
await runScript('nyc', ['mocha', '.licia/test/' + modName]);
} else {
await runScript('karma', ['start', '.licia/karma.conf.js']);
Expand Down

0 comments on commit ee64e4b

Please sign in to comment.