From fcfbe541ee5d1144e223bf05f75685a3878f76c1 Mon Sep 17 00:00:00 2001 From: ZWkang Date: Wed, 1 Sep 2021 20:48:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=A5=BD=E4=B9=85=E5=A5=BD=E4=B9=85=E7=9A=84=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-easy-assert/index.js | 31 ++++++ simple-easy-assert/package.json | 15 +++ simple-easy-assert/pnpm-lock.yaml | 174 ++++++++++++++++++++++++++++++ simple-easy-assert/running.js | 54 ++++++++++ 4 files changed, 274 insertions(+) create mode 100644 simple-easy-assert/index.js create mode 100644 simple-easy-assert/package.json create mode 100644 simple-easy-assert/pnpm-lock.yaml create mode 100644 simple-easy-assert/running.js diff --git a/simple-easy-assert/index.js b/simple-easy-assert/index.js new file mode 100644 index 0000000..30e07af --- /dev/null +++ b/simple-easy-assert/index.js @@ -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).严格相等 +}) + + + diff --git a/simple-easy-assert/package.json b/simple-easy-assert/package.json new file mode 100644 index 0000000..7d10ea4 --- /dev/null +++ b/simple-easy-assert/package.json @@ -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" + } +} diff --git a/simple-easy-assert/pnpm-lock.yaml b/simple-easy-assert/pnpm-lock.yaml new file mode 100644 index 0000000..a9bb043 --- /dev/null +++ b/simple-easy-assert/pnpm-lock.yaml @@ -0,0 +1,174 @@ +lockfileVersion: 5.3 + +specifiers: + chalk: ^4.1.2 + ctressa: ^1.2.0 + +devDependencies: + chalk: 4.1.2 + ctressa: 1.2.0 + +packages: + + /ansi-styles/4.3.0: + resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} + engines: {node: '>=8'} + dependencies: + color-convert: 2.0.1 + dev: true + + /call-bind/1.0.2: + resolution: {integrity: sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==} + dependencies: + function-bind: 1.1.1 + get-intrinsic: 1.1.1 + dev: true + + /chalk/4.1.2: + resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} + engines: {node: '>=10'} + dependencies: + ansi-styles: 4.3.0 + supports-color: 7.2.0 + dev: true + + /color-convert/2.0.1: + resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} + engines: {node: '>=7.0.0'} + dependencies: + color-name: 1.1.4 + dev: true + + /color-name/1.1.4: + resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + dev: true + + /ctressa/1.2.0: + resolution: {integrity: sha512-QWHL5O5Ii4QsX3ZlgVwbR9dzG0OsFHrZSt8nFVOJGWmgDc1CT1pQRPGZF/8y46WuBhxoCswgtQVOSwNi1aF8lA==} + dependencies: + debug: 4.3.2 + deep-equal: 1.1.1 + transitivePeerDependencies: + - supports-color + dev: true + + /debug/4.3.2: + resolution: {integrity: sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + dependencies: + ms: 2.1.2 + dev: true + + /deep-equal/1.1.1: + resolution: {integrity: sha512-yd9c5AdiqVcR+JjcwUQb9DkhJc8ngNr0MahEBGvDiJw8puWab2yZlh+nkasOnZP+EGTAP6rRp2JzJhJZzvNF8g==} + dependencies: + is-arguments: 1.1.1 + is-date-object: 1.0.5 + is-regex: 1.1.4 + object-is: 1.1.5 + object-keys: 1.1.1 + regexp.prototype.flags: 1.3.1 + dev: true + + /define-properties/1.1.3: + resolution: {integrity: sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==} + engines: {node: '>= 0.4'} + dependencies: + object-keys: 1.1.1 + dev: true + + /function-bind/1.1.1: + resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==} + dev: true + + /get-intrinsic/1.1.1: + resolution: {integrity: sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==} + dependencies: + function-bind: 1.1.1 + has: 1.0.3 + has-symbols: 1.0.2 + dev: true + + /has-flag/4.0.0: + resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} + engines: {node: '>=8'} + dev: true + + /has-symbols/1.0.2: + resolution: {integrity: sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==} + engines: {node: '>= 0.4'} + dev: true + + /has-tostringtag/1.0.0: + resolution: {integrity: sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==} + engines: {node: '>= 0.4'} + dependencies: + has-symbols: 1.0.2 + dev: true + + /has/1.0.3: + resolution: {integrity: sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==} + engines: {node: '>= 0.4.0'} + dependencies: + function-bind: 1.1.1 + dev: true + + /is-arguments/1.1.1: + resolution: {integrity: sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.2 + has-tostringtag: 1.0.0 + dev: true + + /is-date-object/1.0.5: + resolution: {integrity: sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==} + engines: {node: '>= 0.4'} + dependencies: + has-tostringtag: 1.0.0 + dev: true + + /is-regex/1.1.4: + resolution: {integrity: sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.2 + has-tostringtag: 1.0.0 + dev: true + + /ms/2.1.2: + resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} + dev: true + + /object-is/1.1.5: + resolution: {integrity: sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.2 + define-properties: 1.1.3 + dev: true + + /object-keys/1.1.1: + resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==} + engines: {node: '>= 0.4'} + dev: true + + /regexp.prototype.flags/1.3.1: + resolution: {integrity: sha512-JiBdRBq91WlY7uRJ0ds7R+dU02i6LKi8r3BuQhNXn+kmeLN+EfHhfjqMRis1zJxnlu88hq/4dx0P2OP3APRTOA==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.2 + define-properties: 1.1.3 + dev: true + + /supports-color/7.2.0: + resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} + engines: {node: '>=8'} + dependencies: + has-flag: 4.0.0 + dev: true diff --git a/simple-easy-assert/running.js b/simple-easy-assert/running.js new file mode 100644 index 0000000..1a264f9 --- /dev/null +++ b/simple-easy-assert/running.js @@ -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() \ No newline at end of file