-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
274 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
|
||
|
||
// describe('earth', function(){ | ||
// beforeEach(function(){ | ||
// console.log('see.. this function is run EACH time, before each describe()') | ||
// }) | ||
// describe('singapre', function(){ | ||
// it('birds should fly', function(){ /** ... */ }) | ||
// }) | ||
// describe('malaysia', function(){ | ||
// it('birds should soar', function(){ /** ... */ }) | ||
// }) | ||
// }) | ||
function add(aNumber, bNumber) { | ||
return aNumber + bNumber; | ||
} | ||
|
||
|
||
const 希望 = require("ctressa") | ||
|
||
test("两个字符串相等吗", () => { | ||
希望("test").和("tests").严格相等 | ||
}) | ||
|
||
test("希望我的add函数能正常吧", () => { | ||
希望(add(1,2)).和(3).严格相等 | ||
}) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "simple-easy-assert", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"chalk": "^4.1.2", | ||
"ctressa": "^1.2.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const chalk = require("chalk") | ||
|
||
|
||
|
||
const testCases = [] | ||
function test(title, cb) { | ||
testCases.push({ | ||
title, | ||
cb | ||
}) | ||
} | ||
|
||
let successTotal = 0; | ||
let failTotal = 0; | ||
|
||
let failCase = []; | ||
|
||
function run() { | ||
for(const testCase of testCases) { | ||
const { title, cb } = testCase; | ||
try { | ||
cb.call(this); | ||
successTotal += 1; | ||
}catch(e) { | ||
failTotal += 1; | ||
failCase.push({ | ||
reason: e.message, | ||
actual: e.actual, | ||
expected: e.expected, | ||
title | ||
}) | ||
} | ||
} | ||
|
||
console.log(`${chalk.green(`Total Test Total: ${successTotal + failTotal}`)} | ||
Tests Suites: ${chalk.green(`${successTotal} total passed`)} | ||
Tests Suites: ${chalk.red(`${failTotal} total failed`)} | ||
`) | ||
|
||
|
||
for(const fail of failCase) { | ||
console.log(` | ||
Test Case: ${fail.title} | ||
Fail reason: ${chalk.red(`${fail.reason}`)} | ||
${chalk.green(`expected ---=> ${fail.expected}`)} | ||
${chalk.red(`actual ---=> ${fail.actual}`)} | ||
`) | ||
} | ||
} | ||
global.test = test; | ||
|
||
require('./index'); | ||
|
||
run() |