From 8e3099cd2abdb4011e1864619173b90ba1169fea Mon Sep 17 00:00:00 2001 From: babebabe <775202038@qq.com> Date: Mon, 22 Aug 2022 03:27:22 -0700 Subject: [PATCH 1/2] test case modified --- index.js | 1 + test/test.spec.js | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 index.js diff --git a/index.js b/index.js new file mode 100644 index 0000000..0ebbd17 --- /dev/null +++ b/index.js @@ -0,0 +1 @@ +require('./test/test.spec'); \ No newline at end of file diff --git a/test/test.spec.js b/test/test.spec.js index 3417042..d44fd7f 100644 --- a/test/test.spec.js +++ b/test/test.spec.js @@ -3,7 +3,7 @@ var assert = require('assert') describe('Array', function() { describe('#indexOf()', function() { test('当value不在数组中应当返回-1', function() { - assert.equal(-1, [1, 2, 3]/* 填空题 */) + assert.equal(-1, [1, 2, 3].includes(10)? 1: -1) }) }) }) @@ -21,7 +21,7 @@ describe('assert', function () { } } // 修改下面代码使得满足测试描述 - assert.equal(a, b) + assert.deepEqual(a, b) }) test('可以捕获并验证函数fn的错误', function () { @@ -29,6 +29,15 @@ describe('assert', function () { xxx; } // 修改下面代码使得满足测试描述 - fn() + assert.throws( + ()=>{ + throw fn(); + }, + (err)=>{ + assert(err instanceof ReferenceError) + return true; + }, + 'unexpected error' + ); }) }) \ No newline at end of file From 774c91024470188e27d5f372cd18108015102b0a Mon Sep 17 00:00:00 2001 From: babebabe <775202038@qq.com> Date: Mon, 22 Aug 2022 04:01:06 -0700 Subject: [PATCH 2/2] delete index.js, jest can look for file by itself --- index.js | 1 - 1 file changed, 1 deletion(-) delete mode 100644 index.js diff --git a/index.js b/index.js deleted file mode 100644 index 0ebbd17..0000000 --- a/index.js +++ /dev/null @@ -1 +0,0 @@ -require('./test/test.spec'); \ No newline at end of file