提交 83d69887 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

add docker bats unit test

上级 7ea3c8b3
......@@ -54,3 +54,4 @@ t.*
/dist/
yarn.lock
.yarn/
.yarn-cache/
......@@ -2,15 +2,25 @@ machine:
services:
- docker
# dependencies:
# pre:
# - sudo apt-get update; sudo apt-get install shellcheck
# Add some environment variables
environment:
BATS_VERSION: 0.4.0
dependencies:
pre:
- sudo apt-get update; sudo apt-get install shellcheck
- curl -s -o "/tmp/v${BATS_VERSION}.tar.gz" -L \
"https://github.com/sstephenson/bats/archive/v${BATS_VERSION}.tar.gz" \
&& tar -xzf "/tmp/v${BATS_VERSION}.tar.gz" -C /tmp/ \
&& sudo bash "/tmp/bats-${BATS_VERSION}/install.sh" /usr/local
test:
override:
- docker info
- docker run -ti -v "$(pwd)":/mnt nlknguyen/alpine-shellcheck bin/*.sh
# - docker run -ti -v "$(pwd)":/mnt nlknguyen/alpine-shellcheck bin/*.sh
- ./script/docker.sh build
- ./script/docker.sh test
- bats test/
deployment:
master:
......
hello, I'm not a javascript file
let i = 3
i = "should set to string because it's type is number"
console.log(i)
{
"name": "with-package-json",
"version": "1.0.0",
"description": "",
"main": "with-require-error.js",
"dependencies": {
"brolog": "^0.3.11"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
import { NotExist } from 'not-exist-at-all-fdsafasdfafsad'
const ne = new NotExist()
console.log(ne) // should not run to here
import { Brolog } from 'brolog'
const brolog = new Brolog()
brolog.info('OK', 'with-import.ts')
const { NotExist } = require('not-exist-at-all-fasdfasdsfaf')
const ne = new NowExist()
console.log(ne) // should not run to here
const { Brolog } = require('brolog')
const brolog = new Brolog()
brolog.info('OK', 'with-require.js')
#!/usr/bin/env bats
function dockerRun() {
docker run -v "$(pwd)":/bot ${IMAGE_NAME:-'wechaty:test'} $@
}
@test "javascript bot" {
cd docker-bot
run dockerRun js-bot.js
[ "$status" -eq 0 ]
}
@test "javascript syntax error" {
cd docker-bot
run dockerRun syntax-error.js
[ "$status" -ne 0 ]
}
@test "typescript bot" {
cd docker-bot
run dockerRun ts-bot.ts
[ "$status" -eq 0 ]
}
@test "typescript type error" {
cd docker-bot
run dockerRun type-error.ts
[ "$status" -ne 0 ]
}
@test "javascript bot with require" {
cd docker-bot/with-package-json/
run dockerRun with-require.js
[ "$status" -eq 0 ]
}
@test "javascript bot require error" {
cd docker-bot/with-package-json/
run dockerRun with-require-error.js
[ "$status" -ne 0 ]
}
@test "typescript bot with import" {
cd docker-bot/with-package-json/
run dockerRun with-import.ts
[ "$status" -eq 0 ]
}
@test "typescript bot with import error" {
cd docker-bot/with-package-json/
run dockerRun with-import-error.ts
[ "$status" -ne 0 ]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册