Skip to content

Commit

Permalink
✅ Use Jest to run tests in example/ (#466)
Browse files Browse the repository at this point in the history
  • Loading branch information
dubzzz committed Nov 3, 2019
1 parent d0162e9 commit 0c965e6
Show file tree
Hide file tree
Showing 10 changed files with 3,555 additions and 168 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
- yarn prebuild
- yarn build:publish-cjs
- yarn build:publish-esm
- yarn build:publish-types
- yarn webbuild
- yarn link
- cd example ;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 15 additions & 9 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@
"version": "1.0.0",
"description": "Examples of usage of fast-check",
"scripts": {
"test:async": "mocha --require ts-node/register async-property/test.ts",
"test:contains": "mocha contains/test.js",
"test:knight": "mocha shadows-of-the-knight-codingame/test.js",
"test:settings": "mocha optional-settings-combination/test.js",
"test:model": "mocha --require ts-node/register model-based-testing/test.ts",
"test:tree": "mocha --require ts-node/register binary-trees/test.ts"
"test": "jest",
"test:async": "jest --testPathPattern async-property",
"test:contains": "jest --testPathPattern contains",
"test:knight": "jest --testPathPattern shadows-of-the-knight-codingame",
"test:settings": "jest --testPathPattern optional-settings-combination",
"test:model": "jest --testPathPattern model-based-testing",
"test:tree": "jest --testPathPattern binary-trees"
},
"devDependencies": {
"@types/jest": "^24.0.21",
"fast-check": "*",
"mocha": "^5.0.0",
"ts-node": "^6.1.0"
"jest": "^24.9.0",
"ts-jest": "^24.1.0"
},
"author": "Nicolas DUBIEN <github@dubien.org>",
"license": "MIT",
"private": true
"private": true,
"jest": {
"moduleFileExtensions": ["ts", "js"],
"transform": {"^.+\\.(ts|tsx)$": "ts-jest"}
}
}
6 changes: 3 additions & 3 deletions example/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ do
failure=`echo "${testUnit}" | cut -d: -f3`

echo "Expect 'yarn test:${name}' to have ${success} passed and ${failure} failed"
yarn "test:${name}" > "output/${name}" 2> /dev/null
yarn "test:${name}" > "output/${name}" 2>&1
cat "output/${name}"

if [ ${success} -ne 0 ]; then
cat "output/${name}" | grep " ${success} passing" >/dev/null 2>&1
cat "output/${name}" | grep "Tests:" | grep "${success} passed," >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Failure [passing]"
status=1
fi
fi
if [ ${failure} -ne 0 ]; then
cat "output/${name}" | grep " ${failure} failing" >/dev/null 2>&1
cat "output/${name}" | grep "Tests:" | grep "${failure} failed," >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Failure [failing]"
status=1
Expand Down
Loading

0 comments on commit 0c965e6

Please sign in to comment.