chore(i8n,learn): processed translations
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
15047f2d90
commit
e5c44a3ae5
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824c367417b2b2512c4c
|
||||
title: 用 Assert.deepEqual() 和 Assert.notDeepEqual() 断言深度相等
|
||||
title: Assert Deep Equality with .deepEqual and .notDeepEqual
|
||||
challengeType: 2
|
||||
forumTopicId: 301587
|
||||
dashedName: assert-deep-equality-with--deepequal-and--notdeepequal
|
||||
@@ -8,17 +8,17 @@ dashedName: assert-deep-equality-with--deepequal-and--notdeepequal
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
`deepEqual()` 断言两个对象是否 deep equal
|
||||
`deepEqual()` asserts that two objects are deep equal.
|
||||
|
||||
# --instructions--
|
||||
|
||||
使用 `assert.deepEqual()` 或者 `assert.notDeepEqual()` 来让测试通过。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#7` in the `Equality` suite, change each `assert` to either `assert.deepEqual` or `assert.notDeepEqual` to make the test pass (should evaluate to `true`). Do not alter the arguments passed to the asserts.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ dashedName: assert-deep-equality-with--deepequal-and--notdeepequal
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—deepEqual 或 notDeepEqual
|
||||
You should choose the correct method for the first assertion - `deepEqual` vs. `notDeepEqual`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +50,7 @@ dashedName: assert-deep-equality-with--deepequal-and--notdeepequal
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—deepEqual 或 notDeepEqual
|
||||
You should choose the correct method for the second assertion - `deepEqual` vs. `notDeepEqual`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824c367417b2b2512c4d
|
||||
title: 比较两个元素的属性
|
||||
title: Compare the Properties of Two Elements
|
||||
challengeType: 2
|
||||
forumTopicId: 301588
|
||||
dashedName: compare-the-properties-of-two-elements
|
||||
@@ -8,15 +8,15 @@ dashedName: compare-the-properties-of-two-elements
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
# --instructions--
|
||||
|
||||
使用 `assert.isAbove()`(大于)或者 `assert.isAtMost()`(小于或等于)来让测试通过。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#8` in the `Comparisons` suite, change each `assert` to either `assert.isAbove` or `assert.isAtMost` to make the test pass (should evaluate to `true`). Do not alter the arguments passed to the asserts.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -30,7 +30,7 @@ dashedName: compare-the-properties-of-two-elements
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isAbove 或 isAtMost
|
||||
You should choose the correct method for the first assertion - `isAbove` vs. `isAtMost`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -48,7 +48,7 @@ dashedName: compare-the-properties-of-two-elements
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isAbove 或 isAtMost
|
||||
You should choose the correct method for the second assertion - `isAbove` vs. `isAtMost`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -62,7 +62,7 @@ dashedName: compare-the-properties-of-two-elements
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isAbove 或 isAtMost
|
||||
You should choose the correct method for the third assertion - `isAbove` vs. `isAtMost`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -80,7 +80,7 @@ dashedName: compare-the-properties-of-two-elements
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isAbove 或 isAtMost
|
||||
You should choose the correct method for the fourth assertion - `isAbove` vs. `isAtMost`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824a367417b2b2512c46
|
||||
title: 了解 JavaScript 断言是如何使用的
|
||||
title: Learn How JavaScript Assertions Work
|
||||
challengeType: 2
|
||||
forumTopicId: 301589
|
||||
dashedName: learn-how-javascript-assertions-work
|
||||
@@ -8,15 +8,15 @@ dashedName: learn-how-javascript-assertions-work
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
# --instructions--
|
||||
|
||||
使用 assert.isNull() 或 assert.isNotNull() 来让测试通过。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#1` in the `Basic Assertions` suite, change each `assert` to either `assert.isNull` or `assert.isNotNull` to make the test pass (should evaluate to `true`). Do not alter the arguments passed to the asserts.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -30,7 +30,7 @@ dashedName: learn-how-javascript-assertions-work
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isNull 或 isNotNull
|
||||
You should choose the correct method for the first assertion - `isNull` vs. `isNotNull`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -44,7 +44,7 @@ dashedName: learn-how-javascript-assertions-work
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the right assertion - isNull vs. isNotNull.
|
||||
You should choose the correct method for the second assertion - `isNull` vs. `isNotNull`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824f367417b2b2512c5a
|
||||
title: 使用 Chai-HTTP 测试 API 响应结果 (3)—PUT 方法
|
||||
title: Run Functional Tests on an API Response using Chai-HTTP III - PUT method
|
||||
challengeType: 2
|
||||
forumTopicId: 301590
|
||||
dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-method
|
||||
@@ -8,11 +8,9 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
接下来,我们将了解如何使用请求的 payload(body)发送数据。
|
||||
|
||||
我们需要测试一个 PUT 请求,`'/travellers'` 接收如下的 JSON 对象:
|
||||
In the next example we'll see how to send data in a request payload (body). We are going to test a PUT request. The `'/travellers'` endpoint accepts a JSON object taking the structure:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -20,7 +18,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me
|
||||
}
|
||||
```
|
||||
|
||||
响应数据如下:
|
||||
The route responds with :
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -28,11 +26,13 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me
|
||||
}
|
||||
```
|
||||
|
||||
更多细节请查看服务器代码。
|
||||
See the server code for more details.
|
||||
|
||||
# --instructions--
|
||||
|
||||
发送
|
||||
Within `tests/2_functional-tests.js`, alter the `'send {surname: "Colombo"}'` test (`// #3`):
|
||||
|
||||
Send the following JSON response as a payload:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -40,11 +40,18 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me
|
||||
}
|
||||
```
|
||||
|
||||
替换 `assert.fail()` 使测试通过。 分别测试 1) `status`,2) `type`,3) `body.name`,4) `body.surname` 请按照以上顺序书写断言,顺序错误会影响此挑战的判定。
|
||||
Check for the following, within the `request.end` callback:
|
||||
|
||||
1. `status`
|
||||
2. `type`
|
||||
3. `body.name`
|
||||
4. `body.surname`
|
||||
|
||||
Follow the assertion order above - we rely on it. Be sure to remove `assert.fail()`, once complete.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -58,7 +65,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me
|
||||
);
|
||||
```
|
||||
|
||||
你需要测试 'res.status' 是否为 200
|
||||
You should test for 'res.status' to be 200.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -74,7 +81,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me
|
||||
);
|
||||
```
|
||||
|
||||
你需要测试 'res.type' 是否为 'application/json'
|
||||
You should test for 'res.type' to be 'application/json'.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -90,7 +97,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me
|
||||
);
|
||||
```
|
||||
|
||||
你需要测试 'res.body.name' 是否为 'Cristoforo'
|
||||
You should test for 'res.body.name' to be 'Cristoforo'.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -106,7 +113,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me
|
||||
);
|
||||
```
|
||||
|
||||
你需要测试 'res.body.surname' 是否为 'Colombo'
|
||||
You should test for 'res.body.surname' to be 'Colombo'.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824f367417b2b2512c5b
|
||||
title: 使用 Chai-HTTP 测试 API 响应结果 (4)—PUT 方法
|
||||
title: Run Functional Tests on an API Response using Chai-HTTP IV - PUT method
|
||||
challengeType: 2
|
||||
forumTopicId: 301591
|
||||
dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-method
|
||||
@@ -8,13 +8,15 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-met
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/). This exercise is similar to the preceding one. Look at it for the details.
|
||||
|
||||
这个练习与上一个类似,我们详细看看。
|
||||
Now that you have seen how it is done, it is your turn to do it from scratch.
|
||||
|
||||
# --instructions--
|
||||
|
||||
发送
|
||||
Within `tests/2_functional-tests.js`, alter the `'send {surname: "da Verrazzano"}'` test (`// #4`):
|
||||
|
||||
Send the following JSON response as a payload to the `/travellers` route:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -22,11 +24,18 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-met
|
||||
}
|
||||
```
|
||||
|
||||
替换 assert.fail(),使测试通过。 分别测试 1) `status`,2) `type`,3) `body.name`,4) `body.surname` 请按照以上顺序书写断言,顺序错误会影响此挑战的判定。
|
||||
Check for the following, within a `request.end` callback:
|
||||
|
||||
1. `status`
|
||||
2. `type`
|
||||
3. `body.name`
|
||||
4. `body.surname`
|
||||
|
||||
Follow the assertion order above - we rely on it. Be sure to remove `assert.fail()`, once complete.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -40,7 +49,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-met
|
||||
);
|
||||
```
|
||||
|
||||
你需要测试 'res.status' 是否为 200
|
||||
You should test for 'res.status' to be 200
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -56,7 +65,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-met
|
||||
);
|
||||
```
|
||||
|
||||
你需要测试 'res.type' 是否为 'application/json'
|
||||
You should test for 'res.type' to be 'application/json'
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -72,7 +81,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-met
|
||||
);
|
||||
```
|
||||
|
||||
你需要测试 'res.body.name' 是否为 'Giovanni'
|
||||
You should test for 'res.body.name' to be 'Giovanni'
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -88,7 +97,7 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-met
|
||||
);
|
||||
```
|
||||
|
||||
你需要测试 'res.body.surname' 是否为 'da Verrazzano'
|
||||
You should test for 'res.body.surname' to be 'da Verrazzano'
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824f367417b2b2512c59
|
||||
title: 使用 Chai-HTTP 进行 API 功能测试 (2)
|
||||
title: Run Functional Tests on API Endpoints using Chai-HTTP II
|
||||
challengeType: 2
|
||||
forumTopicId: 301592
|
||||
dashedName: run-functional-tests-on-api-endpoints-using-chai-http-ii
|
||||
@@ -8,17 +8,17 @@ dashedName: run-functional-tests-on-api-endpoints-using-chai-http-ii
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
# --instructions--
|
||||
|
||||
测试 status 和 `text.response`。替换 `assert.fail()` 使测试通过。
|
||||
Within `tests/2_functional-tests.js`, alter the `'Test GET /hello with your name'` test (`// #2`) to assert the `status` and the `text` response to make the test pass.
|
||||
|
||||
请把 name 的值添加到 query 结尾:`?name=<your_name>`,后端将会返回 `'hello <your_name>'`。
|
||||
Send your name in the query, appending `?name=<your_name>` to the route. The endpoint responds with `'hello <your_name>'`.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ dashedName: run-functional-tests-on-api-endpoints-using-chai-http-ii
|
||||
);
|
||||
```
|
||||
|
||||
你需要测试 'res.status' 是否为 200
|
||||
You should test for 'res.status' == 200
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -48,7 +48,7 @@ dashedName: run-functional-tests-on-api-endpoints-using-chai-http-ii
|
||||
);
|
||||
```
|
||||
|
||||
你需要测试 'res.text' 是否为 'hello Guest'
|
||||
You should test for 'res.text' == 'hello Guest'
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824e367417b2b2512c58
|
||||
title: 使用 Chai-HTTP 进行 API 功能测试 (1)
|
||||
title: Run Functional Tests on API Endpoints using Chai-HTTP
|
||||
challengeType: 2
|
||||
forumTopicId: 301593
|
||||
dashedName: run-functional-tests-on-api-endpoints-using-chai-http
|
||||
@@ -8,17 +8,43 @@ dashedName: run-functional-tests-on-api-endpoints-using-chai-http
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
Mocha allows testing asyncronous operations. There is a small (BIG) difference. Can you spot it?
|
||||
|
||||
We can test our API endpoints using a plugin, called `chai-http`. Let's see how it works. And remember, API calls are asynchronous.
|
||||
|
||||
The following is an example of a test using `chai-http` for the `'GET /hello?name=[name] => "hello [name]"'` suite. The test sends a name string in a url query string (`?name=John`) using a `GET`request to the `server`. In the `end` method's callback function, the response object (`res`) is received and contains the `status` property. The first `assert.equal` checks if the status is equal to `200`. The second `assert.equal` checks that the response string (`res.text`) is equal to `"hello John"`.
|
||||
|
||||
```js
|
||||
suite('GET /hello?name=[name] => "hello [name]"', function () {
|
||||
test("?name=John", function (done) {
|
||||
chai
|
||||
.request(server)
|
||||
.get("/hello?name=John")
|
||||
.end(function (err, res) {
|
||||
assert.equal(res.status, 200, "response status should be 200");
|
||||
assert.equal(
|
||||
res.text,
|
||||
"hello John",
|
||||
'response should be "hello John"'
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
Notice the `done` parameter in the test's callback function. Calling it at the end without an argument is necessary to signal successful asynchronous completion.
|
||||
|
||||
# --instructions--
|
||||
|
||||
测试 status 和 `text.response`。替换 `assert.fail()` 使测试通过。
|
||||
Within `tests/2_functional-tests.js`, alter the `'Test GET /hello with no name'` test (`// #1`) to assert the `status` and the `text` response to make the test pass. Do not alter the arguments passed to the asserts.
|
||||
|
||||
不要在 query 中传入 name,后端将会返回 "hello Guest"。
|
||||
There should be no name in the query; the endpoint responds with `hello Guest`.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +58,7 @@ dashedName: run-functional-tests-on-api-endpoints-using-chai-http
|
||||
);
|
||||
```
|
||||
|
||||
你需要测试 'res.status' 是否为 200
|
||||
You should test for 'res.status' == 200
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -48,7 +74,7 @@ dashedName: run-functional-tests-on-api-endpoints-using-chai-http
|
||||
);
|
||||
```
|
||||
|
||||
你需要测试 'res.text' 是否为 'hello Guest'
|
||||
You should test for 'res.text' == 'hello Guest'
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d8250367417b2b2512c5d
|
||||
title: 使用 headless 浏览器运行功能测试 (2)
|
||||
id: 5f8884f4c46685731aabfc41
|
||||
title: Run Functional Tests Using a Headless Browser II
|
||||
challengeType: 2
|
||||
forumTopicId: 301594
|
||||
dashedName: run-functional-tests-using-a-headless-browser-ii
|
||||
@@ -8,17 +8,27 @@ dashedName: run-functional-tests-using-a-headless-browser-ii
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
# --instructions--
|
||||
|
||||
此挑战与之前的挑战十分类似。
|
||||
Within `tests/2_functional-tests.js`, in the `'submit "surname" : "Vespucci" - write your e2e test...'` test (`// #6`), automate filling-in and submitting the form from scratch:
|
||||
|
||||
请阅读此挑战给出的代码指引,按顺序书写断言。顺序错误会影响此挑战的判定。
|
||||
1. Fill in the form with the `surname` of `Vespucci`
|
||||
2. Submit it pressing `'submit'` button
|
||||
|
||||
Within the callback:
|
||||
|
||||
1. assert that status is `200`
|
||||
2. assert that the text inside the element `span#name` is `'Amerigo'`
|
||||
3. assert that the text inside the element `span#surname` is `'Vespucci'`
|
||||
4. assert that the element(s) `span#dates` exist and their count is `1`
|
||||
|
||||
Do not forget to to remove the `assert.fail()` call.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +42,7 @@ dashedName: run-functional-tests-using-a-headless-browser-ii
|
||||
);
|
||||
```
|
||||
|
||||
Headless browser 应成功执行请求
|
||||
You should assert that the headless browser request succeeded.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -46,7 +56,7 @@ Headless browser 应成功执行请求
|
||||
);
|
||||
```
|
||||
|
||||
元素 'span#name' 中的文字应为 'Amerigo'.
|
||||
You should assert that the text inside the element 'span#name' is 'Amerigo'.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -62,7 +72,7 @@ Headless browser 应成功执行请求
|
||||
);
|
||||
```
|
||||
|
||||
元素 'span#surname' 中的文字应为 'Vespucci'.
|
||||
You should assert that the text inside the element 'span#surname' is 'Vespucci'.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -78,7 +88,7 @@ Headless browser 应成功执行请求
|
||||
);
|
||||
```
|
||||
|
||||
元素 'span#dates' 应存在,并且只有一个
|
||||
You should assert that the element 'span#dates' exist and its count is 1.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824f367417b2b2512c5c
|
||||
title: 使用 headless 浏览器运行功能测试 (1)
|
||||
id: 587d8250367417b2b2512c5d
|
||||
title: Run Functional Tests using a Headless Browser
|
||||
challengeType: 2
|
||||
forumTopicId: 301595
|
||||
dashedName: run-functional-tests-using-a-headless-browser
|
||||
@@ -8,21 +8,52 @@ dashedName: run-functional-tests-using-a-headless-browser
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
在这一项挑战中,我们将会使用 Headless Browser(无头浏览器)模拟人机交互。
|
||||
In the HTML main view we provided a input form. It sends data to the `PUT /travellers` endpoint that we used above with an Ajax request. When the request successfully completes, the client code appends a `<div>` containing the info returned by the call to the DOM. Here is an example of how to interact with this form:
|
||||
|
||||
[无头浏览器](https://en.wikipedia.org/wiki/Headless_browser) 是一种没有图形用户界面的浏览器。这类工具对网页调试特别有效,因为它们可以跟普通浏览器一样理解和渲染 HTML,CSS 和 JavaScript。
|
||||
```js
|
||||
test('#test - submit the input "surname" : "Polo"', function (done) {
|
||||
browser.fill('surname', 'Polo').pressButton('submit', function () {
|
||||
browser.assert.success();
|
||||
browser.assert.text('span#name', 'Marco');
|
||||
browser.assert.text('span#surname', 'Polo');
|
||||
browser.assert.element('span#dates', 1);
|
||||
done();
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
First, the `fill` method of the `browser` object fills the `surname` field of the form with the value `'Polo'`. Immediately after, the `pressButton` method invokes the `submit` event listener of the form. The `pressButton` method is asynchronous.
|
||||
|
||||
Then, once a response is received from the AJAX request, a few assertions are made confirming:
|
||||
|
||||
1. The status of the response is `200`
|
||||
2. The text within the `<span id='name'></span>` element matches `'Marco'`
|
||||
3. The text within the `<span id='surname'></span>` element matches `'Polo'`
|
||||
4. The there is `1` `<span id='dates'></span>` element.
|
||||
|
||||
Finally, the `done` callback is invoked, which is needed due to the asynchronous test.
|
||||
|
||||
# --instructions--
|
||||
|
||||
在这个挑战中,我们将使用 Zombie.JS。它是一款完全基于 JS 的轻量级浏览器,不需要安装其他二进制文件。这个特性让它轻松地在如 Repl.it 的环境下使用。除此之外,还有很多(更强大的)Headless Browser 选项。
|
||||
Within `tests/2_functional-tests.js`, in the `'submit "surname" : "Colombo" - write your e2e test...'` test (`// #5`), automate filling-in and submitting the form:
|
||||
|
||||
请阅读此挑战给出的代码指引,按顺序书写断言。顺序错误会影响此挑战的判定。
|
||||
1. Fill in the form
|
||||
2. Submit it pressing `'submit'` button.
|
||||
|
||||
Within the callback:
|
||||
|
||||
1. assert that status is OK `200`
|
||||
2. assert that the text inside the element `span#name` is `'Cristoforo'`
|
||||
3. assert that the text inside the element `span#surname` is `'Colombo'`
|
||||
4. assert that the element(s) `span#dates` exist and their count is `1`
|
||||
|
||||
Do not forget to remove the `assert.fail()` call.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -36,7 +67,7 @@ dashedName: run-functional-tests-using-a-headless-browser
|
||||
);
|
||||
```
|
||||
|
||||
Headless browser 应成功执行请求
|
||||
You should assert that the headless browser request succeeded.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +81,7 @@ Headless browser 应成功执行请求
|
||||
);
|
||||
```
|
||||
|
||||
元素 'span#name' 中的文字应为 'Cristoforo'
|
||||
You should assert that the text inside the element 'span#name' is 'Cristoforo'.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -66,7 +97,7 @@ Headless browser 应成功执行请求
|
||||
);
|
||||
```
|
||||
|
||||
元素 'span#surname' 中的文字应为 'Colombo'.
|
||||
You should assert that the text inside the element 'span#surname' is 'Colombo'.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -82,7 +113,7 @@ Headless browser 应成功执行请求
|
||||
);
|
||||
```
|
||||
|
||||
元素 'span#dates' 应存在,并且只有一个
|
||||
You should assert that the element 'span#dates' exist and its count is 1.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
---
|
||||
id: 5f8884f4c46685731aabfc41
|
||||
id: 587d824f367417b2b2512c5c
|
||||
title: Simulate Actions Using a Headless Browser
|
||||
challengeType: 2
|
||||
dashedName: simulate-actions-using-a-headless-browser
|
||||
@@ -9,21 +9,43 @@ dashedName: simulate-actions-using-a-headless-browser
|
||||
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
In the next challenges we are going to simulate the human interaction with a page using a device called 'Headless Browser'.
|
||||
|
||||
A headless browser is a web browser without a graphical user interface. This kind of tool is particularly useful for testing web pages, as it is able to render and understand HTML, CSS, and JavaScript the same way a browser would.
|
||||
|
||||
For these challenges we are using Zombie.JS. It's a lightweight browser which is totally based on JS, without relying on additional binaries to be installed. This feature makes it usable in an environment such as Repl.it. There are many other (more powerful) options.
|
||||
|
||||
Mocha allows you to prepare the ground running some code before the actual tests. This can be useful for example to create items in the database, which will be used in the successive tests.
|
||||
|
||||
With a headless browser, before the actual testing, we need to **visit** the page we are going to inspect. The `suiteSetup` 'hook' is executed only once at the suite startup. Other different hook types can be executed before each test, after each test, or at the end of a suite. See the Mocha docs for more information.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Within `tests/2_functional-tests.js`, in the `'submit "surname" : "Vespucci" - write your e2e test...'` test (`// #6`), automate filling-in and submitting the form from scratch:
|
||||
Within `tests/2_functional-tests.js`, immediately after the `Browser` declaration, add your project URL to the `site` property of the variable:
|
||||
|
||||
1. Fill in the form with the `surname` of `Vespucci`
|
||||
2. Submit it pressing `'submit'` button
|
||||
```js
|
||||
Browser.site = 'https://sincere-cone.gomix.me'; // Your URL here
|
||||
```
|
||||
|
||||
Within the callback:
|
||||
If you are testing on a local environment replace the line above with
|
||||
|
||||
1. assert that status is `200`
|
||||
2. assert that the text inside the element `span#name` is `'Amerigo'`
|
||||
3. assert that the text inside the element `span#surname` is `'Vespucci'`
|
||||
4. assert that the element(s) `span#dates` exist and their count is `1`
|
||||
```js
|
||||
Browser.localhost('example.com', process.env.PORT || 3000);
|
||||
```
|
||||
|
||||
Do not forget to to remove the `assert.fail()` call.
|
||||
Within `tests/2_functional-tests.js`, at the root level of the `'Functional Tests with Zombie.js'` suite, instantiate a new instance of the `Browser` object with the following code:
|
||||
|
||||
```js
|
||||
const browser = new Browser();
|
||||
```
|
||||
|
||||
Then, use the `suiteSetup` hook to direct the `browser` to the `/` route with the following code:
|
||||
|
||||
```js
|
||||
suiteSetup(function(done) {
|
||||
return browser.visit('/', done);
|
||||
});
|
||||
```
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -31,71 +53,11 @@ All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then(
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
You should assert that the headless browser request succeeded.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[0].method, 'browser.success');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
You should assert that the text inside the element 'span#name' is 'Amerigo'.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[1].method, 'browser.text');
|
||||
assert.match(data.assertions[1].args[0], /('|")span#name\1/);
|
||||
assert.match(data.assertions[1].args[1], /('|")Amerigo\1/);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
You should assert that the text inside the element 'span#surname' is 'Vespucci'.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[2].method, 'browser.text');
|
||||
assert.match(data.assertions[2].args[0], /('|")span#surname\1/);
|
||||
assert.match(data.assertions[2].args[1], /('|")Vespucci\1/);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
You should assert that the element 'span#dates' exist and its count is 1.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[3].method, 'browser.element');
|
||||
assert.match(data.assertions[3].args[0], /('|")span#dates\1/);
|
||||
assert.equal(data.assertions[3].args[1], 1);
|
||||
data.slice(0, 4).forEach((test) => {
|
||||
assert.equal(test.state, 'passed');
|
||||
})
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
|
@@ -1,32 +1,32 @@
|
||||
---
|
||||
id: 587d824b367417b2b2512c49
|
||||
title: 测试真实性
|
||||
title: Test for Truthiness
|
||||
challengeType: 2
|
||||
videoUrl: ''
|
||||
forumTopicId: 301596
|
||||
dashedName: test-for-truthiness
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
`isTrue()` 仅当给出的值为 Boolean 的 `true` 时可以通过测试;`isNotTrue()` 则会在给出除 `true` 以外的值时通过测试。
|
||||
`isTrue()` will test for the boolean value `true` and `isNotTrue()` will pass when given anything but the boolean value of `true`.
|
||||
|
||||
```js
|
||||
assert.isTrue(true, '可以通过,因为值的类型是布尔且值为 true');
|
||||
assert.isTrue('true', '不能通过,因为值的类型是字符串);
|
||||
assert.isTrue(1, '不过能通过,因为值是数字 1');
|
||||
assert.isTrue(true, 'this will pass with the boolean value true');
|
||||
assert.isTrue('true', 'this will NOT pass with the string value "true"');
|
||||
assert.isTrue(1, 'this will NOT pass with the number value 1');
|
||||
```
|
||||
|
||||
`isFalse()` 和 `isNotFalse()` 同样存在,表现与上面提到的两个方法类似。
|
||||
`isFalse()` and `isNotFalse()` also exist, and behave similarly to their true counterparts except they look for the boolean value of `false`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
使用 `assert.isTrue()` 或 `assert.isNotTrue()` 让测试通过。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#4` in the `Basic Assertions` suite, change each `assert` to either `assert.isTrue` or `assert.isNotTrue` to make the test pass (should evaluate to `true`). Do not alter the arguments passed to the asserts.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -40,7 +40,7 @@ assert.isTrue(1, '不过能通过,因为值是数字 1');
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isTrue 或 isNotTrue
|
||||
You should choose the correct method for the first assertion - `isTrue` vs. `isNotTrue`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -54,7 +54,7 @@ assert.isTrue(1, '不过能通过,因为值是数字 1');
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isTrue 或 isNotTrue
|
||||
You should choose the correct method for the second assertion - `isTrue` vs. `isNotTrue`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -72,7 +72,7 @@ assert.isTrue(1, '不过能通过,因为值是数字 1');
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isTrue 或 isNotTrue
|
||||
You should choose the correct method for the third assertion - `isTrue` vs. `isNotTrue`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824d367417b2b2512c53
|
||||
title: 测试字符串是否包含子字符串
|
||||
title: Test if a String Contains a Substring
|
||||
challengeType: 2
|
||||
forumTopicId: 301597
|
||||
dashedName: test-if-a-string-contains-a-substring
|
||||
@@ -8,17 +8,17 @@ dashedName: test-if-a-string-contains-a-substring
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
`include()` 和 `notInclude()` 同样可以用于字符串。 `include()` 用于断言字符串中包含某个子字符串。
|
||||
`include()` and `notInclude()` work for strings too! `include()` asserts that the actual string contains the expected substring.
|
||||
|
||||
# --instructions--
|
||||
|
||||
使用 `assert.include()` 或 `assert.notInclude()` 让测试通过。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#14` in the `Strings` suite, change each `assert` to either `assert.include` or `assert.notInclude` to make the test pass (should evaluate to `true`). Do not alter the arguments passed to the asserts.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ dashedName: test-if-a-string-contains-a-substring
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—include 或 notInclude
|
||||
You should choose the correct method for the first assertion - `include` vs. `notInclude`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +50,7 @@ dashedName: test-if-a-string-contains-a-substring
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—include 或 notInclude
|
||||
You should choose the correct method for the second assertion - `include` vs. `notInclude`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824c367417b2b2512c4f
|
||||
title: 测试某个值是否在特定范围内
|
||||
title: Test if a Value Falls within a Specific Range
|
||||
challengeType: 2
|
||||
forumTopicId: 301598
|
||||
dashedName: test-if-a-value-falls-within-a-specific-range
|
||||
@@ -8,19 +8,23 @@ dashedName: test-if-a-value-falls-within-a-specific-range
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
`.approximately(actual, expected, delta, [message])` 断言待测试的值处于 `expected` +/- `delta` 的范围内。
|
||||
```javascript
|
||||
.approximately(actual, expected, delta, [message])
|
||||
```
|
||||
|
||||
Asserts that the `actual` is equal to `expected`, to within a +/- `delta` range.
|
||||
|
||||
# --instructions--
|
||||
|
||||
使用 `assert.approximately()` 让测试通过。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#10` in the `Comparisons` suite, change each `assert` to `assert.approximately` to make the test pass (should evaluate to `true`).
|
||||
|
||||
选择最小范围(第三个参数)来通过所有测试。它应该小于 1。
|
||||
Choose the minimum range (3rd parameter) to make the test always pass. It should be less than 1.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -34,7 +38,7 @@ dashedName: test-if-a-value-falls-within-a-specific-range
|
||||
);
|
||||
```
|
||||
|
||||
你应使用 approximately(actual, expected, range) 并选择正确的范围
|
||||
You should choose the correct range for the first assertion - `approximately(actual, expected, range)`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -53,7 +57,7 @@ dashedName: test-if-a-value-falls-within-a-specific-range
|
||||
);
|
||||
```
|
||||
|
||||
你应使用 approximately(actual, expected, range) 并选择正确的范围
|
||||
You should choose the correct range for the second assertion - `approximately(actual, expected, range)`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824d367417b2b2512c52
|
||||
title: 测试某个值是否为字符串
|
||||
title: Test if a Value is a String
|
||||
challengeType: 2
|
||||
forumTopicId: 301599
|
||||
dashedName: test-if-a-value-is-a-string
|
||||
@@ -8,17 +8,17 @@ dashedName: test-if-a-value-is-a-string
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
`isString` 或 `isNotString` 断言一个值是否为字符串。
|
||||
`isString` or `isNotString` asserts that the actual value is a string.
|
||||
|
||||
# --instructions--
|
||||
|
||||
使用 `assert.isString()` 或 `assert.isNotString()` 让所有测试通过。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#13` in the `Strings` suite, change each `assert` to either `assert.isString` or `assert.isNotString` to make the test pass (should evaluate to `true`). Do not alter the arguments passed to the asserts.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ dashedName: test-if-a-value-is-a-string
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isString 或 isNotString
|
||||
You should choose the correct method for the first assertion - `isString` vs. `isNotString`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +50,7 @@ dashedName: test-if-a-value-is-a-string
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isString 或 isNotString
|
||||
You should choose the correct method for the second assertion - `isString` vs. `isNotString`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -68,7 +68,7 @@ dashedName: test-if-a-value-is-a-string
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isString 或 isNotString
|
||||
You should choose the correct method for the third assertion - `isString` vs. `isNotString`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824d367417b2b2512c50
|
||||
title: 测试某个值是否为数组
|
||||
title: Test if a Value is an Array
|
||||
challengeType: 2
|
||||
forumTopicId: 301600
|
||||
dashedName: test-if-a-value-is-an-array
|
||||
@@ -8,15 +8,15 @@ dashedName: test-if-a-value-is-an-array
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
# --instructions--
|
||||
|
||||
使用 `assert.isArray()` 或 `assert.isNotArray()` 让所有测试通过。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#11` in the `Arrays` suite, change each `assert` to either `assert.isArray` or `assert.isNotArray` to make the test pass (should evaluate to `true`). Do not alter the arguments passed to the asserts.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -30,7 +30,7 @@ dashedName: test-if-a-value-is-an-array
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isArray 或 isNotArray
|
||||
You should choose the correct method for the first assertion - `isArray` vs. `isNotArray`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -48,7 +48,7 @@ dashedName: test-if-a-value-is-an-array
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isArray 或 isNotArray
|
||||
You should choose the correct method for the second assertion - `isArray` vs. `isNotArray`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824e367417b2b2512c56
|
||||
title: 测试值是否为特定数据结构类型
|
||||
title: Test if a Value is of a Specific Data Structure Type
|
||||
challengeType: 2
|
||||
forumTopicId: 301601
|
||||
dashedName: test-if-a-value-is-of-a-specific-data-structure-type
|
||||
@@ -8,17 +8,17 @@ dashedName: test-if-a-value-is-of-a-specific-data-structure-type
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
`#typeOf` 断言一个值的类型符合给定的类型,这个类型与 `Object.prototype.toString` 一致。
|
||||
`#typeOf` asserts that value's type is the given string, as determined by `Object.prototype.toString`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
使用 `assert.typeOf()` 或 `assert.notTypeOf()` 让所有测试通过。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#17` in the `Objects` suite, change each `assert` to either `assert.typeOf` or `assert.notTypeOf` to make the test pass (should evaluate to `true`). Do not alter the arguments passed to the asserts.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ dashedName: test-if-a-value-is-of-a-specific-data-structure-type
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—typeOf 或 notTypeOf
|
||||
You should choose the correct method for the first assertion - `typeOf` vs. `notTypeOf`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +50,7 @@ dashedName: test-if-a-value-is-of-a-specific-data-structure-type
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—typeOf 或 notTypeOf
|
||||
You should choose the correct method for the second assertion - `typeOf` vs. `notTypeOf`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -68,7 +68,7 @@ dashedName: test-if-a-value-is-of-a-specific-data-structure-type
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—typeOf 或 notTypeOf
|
||||
You should choose the correct method for the third assertion - `typeOf` vs. `notTypeOf`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -86,7 +86,7 @@ dashedName: test-if-a-value-is-of-a-specific-data-structure-type
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—typeOf 或 notTypeOf
|
||||
You should choose the correct method for the fourth assertion - `typeOf` vs. `notTypeOf`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -104,7 +104,7 @@ dashedName: test-if-a-value-is-of-a-specific-data-structure-type
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—typeOf 或 notTypeOf
|
||||
You should choose the correct method for the fifth assertion - `typeOf` vs. `notTypeOf`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824b367417b2b2512c47
|
||||
title: 测试变量或函数是否已定义
|
||||
title: Test if a Variable or Function is Defined
|
||||
challengeType: 2
|
||||
forumTopicId: 301602
|
||||
dashedName: test-if-a-variable-or-function-is-defined
|
||||
@@ -8,15 +8,15 @@ dashedName: test-if-a-variable-or-function-is-defined
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
# --instructions--
|
||||
|
||||
使用 `assert.isDefined()` 或 `assert.isUndefined()` 让测试通过。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#2` in the `Basic Assertions` suite, change each `assert` to either `assert.isDefined()` or `assert.isUndefined()` to make the test pass (should evaluate to `true`). Do not alter the arguments passed to the asserts.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -30,7 +30,7 @@ dashedName: test-if-a-variable-or-function-is-defined
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—idDefined 或 idUndefined
|
||||
You should choose the correct method for the first assertion - `isDefined` vs. `isUndefined`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -48,7 +48,7 @@ dashedName: test-if-a-variable-or-function-is-defined
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—idDefined 或 idUndefined
|
||||
You should choose the correct method for the second assertion - `isDefined` vs. `isUndefined`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -66,7 +66,7 @@ dashedName: test-if-a-variable-or-function-is-defined
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—idDefined 或 idUndefined
|
||||
You should choose the correct method for the third assertion - `isDefined` vs. `isUndefined`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824d367417b2b2512c51
|
||||
title: 测试数组是否包含项目
|
||||
title: Test if an Array Contains an Item
|
||||
challengeType: 2
|
||||
forumTopicId: 301603
|
||||
dashedName: test-if-an-array-contains-an-item
|
||||
@@ -8,15 +8,15 @@ dashedName: test-if-an-array-contains-an-item
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
# --instructions--
|
||||
|
||||
使用 `assert.include()` 或 `assert.notInclude()` 让所有测试通过。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#12` in the `Arrays` suite, change each `assert` to either `assert.include` or `assert.notInclude` to make the test pass (should evaluate to `true`). Do not alter the arguments passed to the asserts.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -30,7 +30,7 @@ dashedName: test-if-an-array-contains-an-item
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—include 或 notInclude
|
||||
You should choose the correct method for the first assertion - `include` vs. `notInclude`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -48,7 +48,7 @@ dashedName: test-if-an-array-contains-an-item
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—include 或 notInclude
|
||||
You should choose the correct method for the second assertion - `include` vs. `notInclude`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824e367417b2b2512c55
|
||||
title: 测试对象是否具有某个属性
|
||||
title: Test if an Object has a Property
|
||||
challengeType: 2
|
||||
forumTopicId: 301604
|
||||
dashedName: test-if-an-object-has-a-property
|
||||
@@ -8,17 +8,17 @@ dashedName: test-if-an-object-has-a-property
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
`property` 断言一个对象含有给定属性。
|
||||
`property` asserts that the actual object has a given property.
|
||||
|
||||
# --instructions--
|
||||
|
||||
使用 `assert.property()` 或者 `assert.notProperty()` 让所有测试通过。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#16` in the `Objects` suite, change each `assert` to either `assert.property` or `assert.notProperty` to make the test pass (should evaluate to `true`). Do not alter the arguments passed to the asserts.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ dashedName: test-if-an-object-has-a-property
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—property 或 notProperty
|
||||
You should choose the correct method for the first assertion - `property` vs. `notProperty`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +50,7 @@ dashedName: test-if-an-object-has-a-property
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—property 或 notProperty
|
||||
You should choose the correct method for the second assertion - `property` vs. `notProperty`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -68,7 +68,7 @@ dashedName: test-if-an-object-has-a-property
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—property 或 notProperty
|
||||
You should choose the correct method for the third assertion - `property` vs. `notProperty`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824e367417b2b2512c57
|
||||
title: 测试对象是否是构造函数的实例
|
||||
title: Test if an Object is an Instance of a Constructor
|
||||
challengeType: 2
|
||||
forumTopicId: 301605
|
||||
dashedName: test-if-an-object-is-an-instance-of-a-constructor
|
||||
@@ -8,17 +8,17 @@ dashedName: test-if-an-object-is-an-instance-of-a-constructor
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
`#instanceOf` 断言一个对象是一个构造器的实例。
|
||||
`#instanceOf` asserts that an object is an instance of a constructor.
|
||||
|
||||
# --instructions--
|
||||
|
||||
使用 `assert.instanceOf()` 或 `assert.notInstanceOf()` 让测试通过。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#18` in the `Objects` suite, change each `assert` to either `assert.instanceOf` or `assert.notInstanceOf` to make the test pass (should evaluate to `true`). Do not alter the arguments passed to the asserts.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ dashedName: test-if-an-object-is-an-instance-of-a-constructor
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—instanceOf 或 notInstanceOf
|
||||
You should choose the correct method for the first assertion - `instanceOf` vs. `notInstanceOf`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +50,7 @@ dashedName: test-if-an-object-is-an-instance-of-a-constructor
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—instanceOf 或 notInstanceOf
|
||||
You should choose the correct method for the second assertion - `instanceOf` vs. `notInstanceOf`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -68,7 +68,7 @@ dashedName: test-if-an-object-is-an-instance-of-a-constructor
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—instanceOf 或 notInstanceOf
|
||||
You should choose the correct method for the third assertion - `instanceOf` vs. `notInstanceOf`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -86,7 +86,7 @@ dashedName: test-if-an-object-is-an-instance-of-a-constructor
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—instanceOf 或 notInstanceOf
|
||||
You should choose the correct method for the fourth assertion - `instanceOf` vs. `notInstanceOf`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824c367417b2b2512c4e
|
||||
title: 测试一个值是否小于或等于另一个值
|
||||
title: Test if One Value is Below or At Least as Large as Another
|
||||
challengeType: 2
|
||||
forumTopicId: 301606
|
||||
dashedName: test-if-one-value-is-below-or-at-least-as-large-as-another
|
||||
@@ -8,17 +8,15 @@ dashedName: test-if-one-value-is-below-or-at-least-as-large-as-another
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
# --instructions--
|
||||
|
||||
Use `assert.isBelow()` (i.e. less than) or `assert.isAtLeast()` (i.e. greater than or equal) to make the tests pass.
|
||||
|
||||
使用 `assert.isBelow()`(小于)或 `assert.isAtLeast()`(大于等于)让所有测试通过。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#9` in the `Comparisons` suite, change each `assert` to either `assert.isBelow` or `assert.isAtLeast` to make the test pass (should evaluate to `true`). Do not alter the arguments passed to the asserts.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +30,7 @@ Use `assert.isBelow()` (i.e. less than) or `assert.isAtLeast()` (i.e. greater th
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isBelow 或 isAtLeast
|
||||
You should choose the correct method for the first assertion - `isBelow` vs. `isAtLeast`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +48,7 @@ Use `assert.isBelow()` (i.e. less than) or `assert.isAtLeast()` (i.e. greater th
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isBelow 或 isAtLeast
|
||||
You should choose the correct method for the second assertion - `isBelow` vs. `isAtLeast`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -68,7 +66,7 @@ Use `assert.isBelow()` (i.e. less than) or `assert.isAtLeast()` (i.e. greater th
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isBelow 或 isAtLeast
|
||||
You should choose the correct method for the third assertion - `isBelow` vs. `isAtLeast`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -82,7 +80,7 @@ Use `assert.isBelow()` (i.e. less than) or `assert.isAtLeast()` (i.e. greater th
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isBelow 或 isAtLeast
|
||||
You should choose the correct method for the fourth assertion - `isBelow` vs. `isAtLeast`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824b367417b2b2512c48
|
||||
title: 使用 Assert.isOk() 和 Assert.isNotOK()
|
||||
title: Use Assert.isOK and Assert.isNotOK
|
||||
challengeType: 2
|
||||
forumTopicId: 301607
|
||||
dashedName: use-assert-isok-and-assert-isnotok
|
||||
@@ -8,17 +8,19 @@ dashedName: use-assert-isok-and-assert-isnotok
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
`isOk()` 用来测试值是否为 `truthy`;`isNotOk()` 用来测试值是否为 `falsy`。 如果你想了解更多关于 truthy 和 falsy 值的内容,请参阅 [Falsy Bouncer](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/falsy-bouncer) 这道挑战题目。
|
||||
`isOk()` will test for a truthy value, and `isNotOk()` will test for a falsy value.
|
||||
|
||||
To learn more about truthy and falsy values, try our [Falsy Bouncer](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/falsy-bouncer) challenge.
|
||||
|
||||
# --instructions--
|
||||
|
||||
使用 `assert.isOk()` 或 `assert.isNotOk()` 让测试通过。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#3` in the `Basic Assertions` suite, change each `assert` to either `assert.isOk()` or `assert.isNotOk()` to make the test pass (should evaluate to `true`). Do not alter the arguments passed to the asserts.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +34,7 @@ dashedName: use-assert-isok-and-assert-isnotok
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isOk 或 isNotOk
|
||||
You should choose the correct method for the first assertion - `isOk` vs. `isNotOk`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -46,7 +48,7 @@ dashedName: use-assert-isok-and-assert-isnotok
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isOk 或 isNotOk
|
||||
You should choose the correct method for the second assertion - `isOk` vs. `isNotOk`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -60,7 +62,7 @@ dashedName: use-assert-isok-and-assert-isnotok
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—isOk 或 isNotOk
|
||||
You should choose the correct method for the third assertion - `isOk` vs. `isNotOk`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824d367417b2b2512c54
|
||||
title: 使用正则表达式测试字符串
|
||||
title: Use Regular Expressions to Test a String
|
||||
challengeType: 2
|
||||
forumTopicId: 301608
|
||||
dashedName: use-regular-expressions-to-test-a-string
|
||||
@@ -8,17 +8,17 @@ dashedName: use-regular-expressions-to-test-a-string
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
`match()` 断言一个值匹配一个正则表达式(第二个参数)。
|
||||
`match()` asserts that the actual value matches the second argument regular expression.
|
||||
|
||||
# --instructions--
|
||||
|
||||
使用 `assert.match()` 让所有测试通过。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#15` in the `Strings` suite, change each `assert` to either `assert.match` or `assert.notMatch` to make the test pass (should evaluate to `true`). Do not alter the arguments passed to the asserts.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ dashedName: use-regular-expressions-to-test-a-string
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—match 或 notMatch
|
||||
You should choose the correct method for the first assertion - `match` vs. `notMatch`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -41,7 +41,7 @@ dashedName: use-regular-expressions-to-test-a-string
|
||||
assert.equal(
|
||||
data.assertions[0].method,
|
||||
'match',
|
||||
"'# name: John Doe, age: 35' matches the regex"
|
||||
"'# name:John Doe, age:35' matches the regex"
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
@@ -50,7 +50,7 @@ dashedName: use-regular-expressions-to-test-a-string
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—match 或 notMatch
|
||||
You should choose the correct method for the second assertion - `match` vs. `notMatch`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -59,7 +59,7 @@ dashedName: use-regular-expressions-to-test-a-string
|
||||
assert.equal(
|
||||
data.assertions[1].method,
|
||||
'notMatch',
|
||||
"'# name: Paul Smith III, age: twenty-four' does not match the regex (the age must be numeric)"
|
||||
"'# name:Paul Smith III, age:twenty-four' does not match the regex (the age must be numeric)"
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824b367417b2b2512c4a
|
||||
title: 用两个等号断言相等
|
||||
title: Use the Double Equals to Assert Equality
|
||||
challengeType: 2
|
||||
forumTopicId: 301609
|
||||
dashedName: use-the-double-equals-to-assert-equality
|
||||
@@ -8,17 +8,17 @@ dashedName: use-the-double-equals-to-assert-equality
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
`equal()` 使用 `==` 比较对象。
|
||||
`equal()` compares objects using `==`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
使用 `assert.equal()` 或 `assert.notEqual()` 让所有测试通过。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#5` in the `Equality` suite, change each `assert` to either `assert.equal` or `assert.notEqual` to make the test pass (should evaluate to `true`). Do not alter the arguments passed to the asserts.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ dashedName: use-the-double-equals-to-assert-equality
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—equal 或 notEqual
|
||||
You should choose the correct method for the first assertion - `equal` vs. `notEqual`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +50,7 @@ dashedName: use-the-double-equals-to-assert-equality
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—equal 或 notEqual
|
||||
You should choose the correct method for the second assertion - `equal` vs. `notEqual`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -68,7 +68,7 @@ dashedName: use-the-double-equals-to-assert-equality
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—equal 或 notEqual
|
||||
You should choose the correct method for the third assertion - `equal` vs. `notEqual`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -86,7 +86,7 @@ dashedName: use-the-double-equals-to-assert-equality
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—equal 或 notEqual
|
||||
You should choose the correct method for the fourth assertion - `equal` vs. `notEqual`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824b367417b2b2512c4b
|
||||
title: 用三个等号断言严格相等
|
||||
title: Use the Triple Equals to Assert Strict Equality
|
||||
challengeType: 2
|
||||
forumTopicId: 301610
|
||||
dashedName: use-the-triple-equals-to-assert-strict-equality
|
||||
@@ -8,17 +8,17 @@ dashedName: use-the-triple-equals-to-assert-strict-equality
|
||||
|
||||
# --description--
|
||||
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
As a reminder, this project is being built upon the following starter project on [Repl.it](https://repl.it/github/freeCodeCamp/boilerplate-mochachai), or cloned from [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
|
||||
|
||||
`strictEqual()` 使用 `===` 比较对象。
|
||||
`strictEqual()` compares objects using `===`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
使用 `assert.strictEqual()` 或 `assert.notStrictEqual()` 让所有测试通过。
|
||||
Within `tests/1_unit-tests.js` under the test labelled `#6` in the `Equality` suite, change each `assert` to either `assert.strictEqual` or `assert.notStrictEqual` to make the test pass (should evaluate to `true`). Do not alter the arguments passed to the asserts.
|
||||
|
||||
# --hints--
|
||||
|
||||
不应有未通过的测试
|
||||
All tests should pass.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ dashedName: use-the-triple-equals-to-assert-strict-equality
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—strictEqual 或 notStrictEqual
|
||||
You should choose the correct method for the first assertion - `strictEqual` vs. `notStrictEqual`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +50,7 @@ dashedName: use-the-triple-equals-to-assert-strict-equality
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—strictEqual 或 notStrictEqual
|
||||
You should choose the correct method for the second assertion - `strictEqual` vs. `notStrictEqual`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -64,7 +64,7 @@ dashedName: use-the-triple-equals-to-assert-strict-equality
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—strictEqual 或 notStrictEqual
|
||||
You should choose the correct method for the third assertion - `strictEqual` vs. `notStrictEqual`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -82,7 +82,7 @@ dashedName: use-the-triple-equals-to-assert-strict-equality
|
||||
);
|
||||
```
|
||||
|
||||
请选择正确的断言—strictEqual 或 notStrictEqual
|
||||
You should choose the correct method for the fourth assertion - `strictEqual` vs. `notStrictEqual`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
Reference in New Issue
Block a user