chore(i8n,curriculum): processed translations (#41551)
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824c367417b2b2512c4c
|
||||
title: Assert Deep Equality with .deepEqual and .notDeepEqual
|
||||
title: 用 Assert.deepEqual() 和 Assert.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--
|
||||
|
||||
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/).
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。 你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
`deepEqual()` asserts that two objects are deep equal.
|
||||
`deepEqual()` 断言两个对象是否深度相等。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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.
|
||||
在 `tests/1_unit-tests.js` 中,在标有 `#7` 的 `Equality` 套件里,将每个 `assert` 替换成 `assert.deepEqual` 或 `assert.notDeepEqual`,让测试通过(应该返回 `true`)。 不要改变传入断言的参数。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
不应有未通过的测试
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the first assertion - `deepEqual` vs. `notDeepEqual`.
|
||||
请为第一个断言选择正确的方法 — `deepEqual` 或 `notDeepEqual`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +50,7 @@ You should choose the correct method for the first assertion - `deepEqual` vs. `
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the second assertion - `deepEqual` vs. `notDeepEqual`.
|
||||
请为第二个断言选择正确的方法 — `deepEqual` 或 `notDeepEqual`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824c367417b2b2512c4d
|
||||
title: Compare the Properties of Two Elements
|
||||
title: 比较两个元素的属性
|
||||
challengeType: 2
|
||||
forumTopicId: 301588
|
||||
dashedName: compare-the-properties-of-two-elements
|
||||
@@ -8,15 +8,15 @@ dashedName: compare-the-properties-of-two-elements
|
||||
|
||||
# --description--
|
||||
|
||||
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/).
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。 你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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.
|
||||
在 `tests/1_unit-tests.js` 中,在标有 `#8` 的 `Comparisons` 套件里,将每个 `assert` 改成 `assert.isAbove` 或 `assert.isAtMost` 方法,让测试通过(结果应该返回 `true`)。 不要改变传入断言的参数。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
不应有未通过的测试
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -30,7 +30,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the first assertion - `isAbove` vs. `isAtMost`.
|
||||
请为第一个断言选择正确的方法 — `isAbove` 或 `isAtMost`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -48,7 +48,7 @@ You should choose the correct method for the first assertion - `isAbove` vs. `is
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the second assertion - `isAbove` vs. `isAtMost`.
|
||||
请为第二个断言选择正确的方法 — `isAbove` 或 `isAtMost`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -62,7 +62,7 @@ You should choose the correct method for the second assertion - `isAbove` vs. `i
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the third assertion - `isAbove` vs. `isAtMost`.
|
||||
请为第三个断言选择正确的方法 — `isAbove` 或 `isAtMost`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -80,7 +80,7 @@ You should choose the correct method for the third assertion - `isAbove` vs. `is
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the fourth assertion - `isAbove` vs. `isAtMost`.
|
||||
请为第四个断言选择正确的方法 — `isAbove` 或 `isAtMost`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824a367417b2b2512c46
|
||||
title: Learn How JavaScript Assertions Work
|
||||
title: 了解 JavaScript 断言的工作原理
|
||||
challengeType: 2
|
||||
forumTopicId: 301589
|
||||
dashedName: learn-how-javascript-assertions-work
|
||||
@@ -8,15 +8,21 @@ dashedName: learn-how-javascript-assertions-work
|
||||
|
||||
# --description--
|
||||
|
||||
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/).
|
||||
你可以采用下面的任意一种方式完成这些挑战:
|
||||
|
||||
- 克隆[这个 GitHub 仓库](https://github.com/freeCodeCamp/boilerplate-mochachai/)并在本地完成项目。
|
||||
- 使用[我们在 Repl.it 上的初始化项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)来完成这些挑战。
|
||||
- 使用一个你喜欢的站点生成器来完成项目。 需要确定包含了我们 GitHub 仓库的所有文件。
|
||||
|
||||
完成本项目后,请将一个正常运行的 demo(项目演示)托管在可以公开访问的平台。 然后在 `Solution Link` 框中提交你的项目 URL。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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.
|
||||
在 `tests/1_unit-tests.js` 文件下 `Basic Assertions` suite 内注释为 `#1` 的地方,将每一个 `assert` 更改为 `assert.isNull` 或 `assert.isNotNull` 以使测试通过(应该返回 `true`)。 不要改变传入断言的参数。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
所有测试都应该通过。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -30,7 +36,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the first assertion - `isNull` vs. `isNotNull`.
|
||||
请为第一个断言选择正确的方法— `isNull` 或 `isNotNull`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -44,7 +50,7 @@ You should choose the correct method for the first assertion - `isNull` vs. `isN
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the second assertion - `isNull` vs. `isNotNull`.
|
||||
请为第二个断言选择正确的方法— `isNull` 或 `isNotNull`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824f367417b2b2512c5a
|
||||
title: Run Functional Tests on an API Response using Chai-HTTP III - PUT method
|
||||
title: 使用 Chai-HTTP III 的 PUT 方法对 API 请求运行功能测试
|
||||
challengeType: 2
|
||||
forumTopicId: 301590
|
||||
dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-method
|
||||
@@ -8,9 +8,9 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-me
|
||||
|
||||
# --description--
|
||||
|
||||
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/).
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
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:
|
||||
接下来,我们将了解如何使用请求的 payload(body)发送数据。 我们需要测试一个 PUT 请求, `'/travellers'` 接收如下的 JSON 对象:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -18,7 +18,7 @@ In the next example we'll see how to send data in a request payload (body). We a
|
||||
}
|
||||
```
|
||||
|
||||
The route responds with :
|
||||
路由响应如下:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -26,13 +26,13 @@ The route responds with :
|
||||
}
|
||||
```
|
||||
|
||||
See the server code for more details.
|
||||
更多细节请查看服务器代码。
|
||||
|
||||
# --instructions--
|
||||
|
||||
Within `tests/2_functional-tests.js`, alter the `'send {surname: "Colombo"}'` test (`// #3`):
|
||||
在 `tests/2_functional-tests.js` 中,修改 `'send {surname: "Colombo"}'` 测试(`// #3`):
|
||||
|
||||
Send the following JSON response as a payload:
|
||||
发送以下 JSON 响应作为有效载荷:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -40,18 +40,18 @@ Send the following JSON response as a payload:
|
||||
}
|
||||
```
|
||||
|
||||
Check for the following, within the `request.end` callback:
|
||||
在 `request.end` 返回中检查以下情况:
|
||||
|
||||
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.
|
||||
请按照以上顺序书写断言,顺序错误会影响系统判定。 完成后,请务必移除 `assert.fail()`。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
应通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -65,7 +65,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should test for 'res.status' to be 200.
|
||||
应测试 “res.status” 是否为 200。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -81,7 +81,7 @@ You should test for 'res.status' to be 200.
|
||||
);
|
||||
```
|
||||
|
||||
You should test for 'res.type' to be 'application/json'.
|
||||
需要测试 “res.type” 是否为 “application/json”。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -97,7 +97,7 @@ You should test for 'res.type' to be 'application/json'.
|
||||
);
|
||||
```
|
||||
|
||||
You should test for 'res.body.name' to be 'Cristoforo'.
|
||||
需要测试 “res.body.name” 是否为 “Cristoforo”。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -113,7 +113,7 @@ You should test for 'res.body.name' to be 'Cristoforo'.
|
||||
);
|
||||
```
|
||||
|
||||
You should test for 'res.body.surname' to be 'Colombo'.
|
||||
需要测试 “res.body.surname” 是否为 “Colombo”。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824f367417b2b2512c5b
|
||||
title: Run Functional Tests on an API Response using Chai-HTTP IV - PUT method
|
||||
title: 使用 Chai-HTTP IV 的 PUT 方法对 API 响应运行功能测试
|
||||
challengeType: 2
|
||||
forumTopicId: 301591
|
||||
dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-method
|
||||
@@ -8,15 +8,15 @@ dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-met
|
||||
|
||||
# --description--
|
||||
|
||||
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.
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。 这个练习与上一个类似, 我们详细看看。
|
||||
|
||||
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`):
|
||||
在 `tests/2_functional-tests.js` 中,修改 `'send {surname: "da Verrazzano"}'` 测试(`// #4`)。
|
||||
|
||||
Send the following JSON response as a payload to the `/travellers` route:
|
||||
发送以下 JSON 响应作为有效载荷到 `/travellers` 路径:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -24,18 +24,18 @@ Send the following JSON response as a payload to the `/travellers` route:
|
||||
}
|
||||
```
|
||||
|
||||
Check for the following, within a `request.end` callback:
|
||||
在 `request.end` 返回中检查以下情况:
|
||||
|
||||
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.
|
||||
请按照以上顺序书写断言,顺序错误会影响系统判定。 完成后请务必删除 `assert.fail()`。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass
|
||||
需要通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -49,7 +49,7 @@ All tests should pass
|
||||
);
|
||||
```
|
||||
|
||||
You should test for 'res.status' to be 200
|
||||
需要测试 “res.status” 是否为 200。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -65,7 +65,7 @@ You should test for 'res.status' to be 200
|
||||
);
|
||||
```
|
||||
|
||||
You should test for 'res.type' to be 'application/json'
|
||||
需要测试 “res.type” 是否为 “application/json”。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -81,7 +81,7 @@ You should test for 'res.type' to be 'application/json'
|
||||
);
|
||||
```
|
||||
|
||||
You should test for 'res.body.name' to be 'Giovanni'
|
||||
需要测试 “res.body.name” 为 “Giovanni”。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -97,7 +97,7 @@ You should test for 'res.body.name' to be 'Giovanni'
|
||||
);
|
||||
```
|
||||
|
||||
You should test for 'res.body.surname' to be 'da Verrazzano'
|
||||
需要测试 “res.body.surname” 是否为 “da Verrazzano”。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824f367417b2b2512c59
|
||||
title: Run Functional Tests on API Endpoints using Chai-HTTP II
|
||||
title: 使用 Chai-HTTP II 在 API 端上运行功能测试
|
||||
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--
|
||||
|
||||
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/).
|
||||
请注意,本项目在[这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。 你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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.
|
||||
在 `tests/2_functional-tests.js` 中,修改 `'Test GET /hello with your name'` 测试(`// #2`),对 `status` 和 `text` 断言。
|
||||
|
||||
Send your name in the query, appending `?name=<your_name>` to the route. The endpoint responds with `'hello <your_name>'`.
|
||||
在查询中发送 name,将 `?name=<your_name>` 添加到路由。 端点响应 `'hello <your_name>'`。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass
|
||||
应通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ All tests should pass
|
||||
);
|
||||
```
|
||||
|
||||
You should test for 'res.status' == 200
|
||||
应测试 “res.status” 是否为 200。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -48,7 +48,7 @@ You should test for 'res.status' == 200
|
||||
);
|
||||
```
|
||||
|
||||
You should test for 'res.text' == 'hello Guest'
|
||||
应测试 “res.text“ 是否为 ”hello Guest“。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824e367417b2b2512c58
|
||||
title: Run Functional Tests on API Endpoints using Chai-HTTP
|
||||
title: 使用 Chai-HTTP 在 API 端上运行功能测试
|
||||
challengeType: 2
|
||||
forumTopicId: 301593
|
||||
dashedName: run-functional-tests-on-api-endpoints-using-chai-http
|
||||
@@ -8,13 +8,13 @@ dashedName: run-functional-tests-on-api-endpoints-using-chai-http
|
||||
|
||||
# --description--
|
||||
|
||||
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/).
|
||||
请注意,本项目在[这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
Mocha allows testing asyncronous operations. There is a small (BIG) difference. Can you spot it?
|
||||
Mocha 允许测试异步操作。 有一个差异, 你能发现它吗?
|
||||
|
||||
We can test our API endpoints using a plugin, called `chai-http`. Let's see how it works. And remember, API calls are asynchronous.
|
||||
我们可以使用一个叫作 `chai-http` 的插件测试 API 端点。 让我们看看它是如何工作的。 请记住,API 调用是异步的。
|
||||
|
||||
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"`.
|
||||
以下是使用 `chai-http` 测试 `'GET /hello?name=[name] => "hello [name]"'` 套件的例子。 测试通过 `GET` 请求在 url 查询字符串 `?name=John` 中发送一个名称字符串给 `server`。 在 `end` 方法的回调函数中,接收包含 `status` 属性的响应对象(`res`)。 第一个 `assert.equal` 检查状态是否为 `200`。 第二个 `assert.equal` 检查响应字符串 `res.text` 是否为 `"hello John"`。
|
||||
|
||||
```js
|
||||
suite('GET /hello?name=[name] => "hello [name]"', function () {
|
||||
@@ -34,17 +34,17 @@ suite('GET /hello?name=[name] => "hello [name]"', function () {
|
||||
});
|
||||
```
|
||||
|
||||
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.
|
||||
请注意测试的回调函数中的 `done` 参数。 在没有传入参数的情况下调用它,是成功完成异步任务所必需的。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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.
|
||||
在 `tests/2_functional-tests.js` 中,修改 `'Test GET /hello with no name'` 测试(`// #1`),对 `status` 和 `text` 使用断言。 不要修改传给断言的参数。
|
||||
|
||||
There should be no name in the query; the endpoint responds with `hello Guest`.
|
||||
不要在 query 中传入 name,端点将会返回 `hello Guest`。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass
|
||||
应通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -58,7 +58,7 @@ All tests should pass
|
||||
);
|
||||
```
|
||||
|
||||
You should test for 'res.status' == 200
|
||||
应测试 “res.status” 是否为 200。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -74,7 +74,7 @@ You should test for 'res.status' == 200
|
||||
);
|
||||
```
|
||||
|
||||
You should test for 'res.text' == 'hello Guest'
|
||||
应测试 “res.text“ 是否为 ”hello Guest“。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5f8884f4c46685731aabfc41
|
||||
title: Run Functional Tests Using a Headless Browser II
|
||||
title: 使用 无头浏览器 II 运行功能测试
|
||||
challengeType: 2
|
||||
forumTopicId: 301594
|
||||
dashedName: run-functional-tests-using-a-headless-browser-ii
|
||||
@@ -8,27 +8,27 @@ dashedName: run-functional-tests-using-a-headless-browser-ii
|
||||
|
||||
# --description--
|
||||
|
||||
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/).
|
||||
请注意,本项目在[这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/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:
|
||||
在 `tests/2_functional-tests.js` 中,`'submit "surname" : "Vespucci" - write your e2e test...'` 测试(`// #6`),自动化填写和提交表单:
|
||||
|
||||
1. Fill in the form with the `surname` of `Vespucci`
|
||||
2. Submit it pressing `'submit'` button
|
||||
1. 在表单中填写 `Vespucci` 的 `surname`。
|
||||
2. 点击 `'submit'` 按钮提交表单
|
||||
|
||||
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`
|
||||
1. 断言状态是正常的 `200`
|
||||
2. 断言元素 `span#name` 中的文本是 `'Amerigo'`
|
||||
3. 断言元素 `span#surname` 元素中的文本是 `'Vespucci'`
|
||||
4. 断言有 `span#dates` 元素,它们的计数是 `1`
|
||||
|
||||
Do not forget to to remove the `assert.fail()` call.
|
||||
不要忘记删除 `assert.fail()` 调用。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
应通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -42,7 +42,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should assert that the headless browser request succeeded.
|
||||
应断言无头浏览器成功执行请求。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -56,7 +56,7 @@ You should assert that the headless browser request succeeded.
|
||||
);
|
||||
```
|
||||
|
||||
You should assert that the text inside the element 'span#name' is 'Amerigo'.
|
||||
应断言元素 “span#surname” 中的文本为 “Vespucci”。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -72,7 +72,7 @@ You should assert that the text inside the element 'span#name' is 'Amerigo'.
|
||||
);
|
||||
```
|
||||
|
||||
You should assert that the text inside the element 'span#surname' is 'Vespucci'.
|
||||
应断言元素 “span#surname” 中的文本为 “Vespucci”。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -88,7 +88,7 @@ You should assert that the text inside the element 'span#surname' is 'Vespucci'.
|
||||
);
|
||||
```
|
||||
|
||||
You should assert that the element 'span#dates' exist and its count is 1.
|
||||
应该断言元素 “span#dates” 存在,且它的值为 1。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d8250367417b2b2512c5d
|
||||
title: Run Functional Tests using a Headless Browser
|
||||
title: 使用无头浏览器运行功能测试
|
||||
challengeType: 2
|
||||
forumTopicId: 301595
|
||||
dashedName: run-functional-tests-using-a-headless-browser
|
||||
@@ -8,9 +8,9 @@ dashedName: run-functional-tests-using-a-headless-browser
|
||||
|
||||
# --description--
|
||||
|
||||
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/).
|
||||
请注意,本项目在[这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。 你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
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:
|
||||
在 HTML 主视图中有一个输入表格。 它发送数据到 `PUT /travellers` 端点,我们在上面的 Ajax 请求中使用。 当请求成功完成时,客户端代码会给 DOM 增加一个包含调用返回信息的 `<div>`。 下面的例子展示了如何使用这个表格:
|
||||
|
||||
```js
|
||||
test('#test - submit the input "surname" : "Polo"', function (done) {
|
||||
@@ -24,36 +24,36 @@ test('#test - submit the input "surname" : "Polo"', function (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.
|
||||
首先, `browser` 对象的 `fill` 方法在表格的 `surname` 字段中填入值 `'Polo'`。 紧接着,`pressButton` 方法调用表单的 `submit` 事件监听器。 `pressButton` 方法是异步的。
|
||||
|
||||
Then, once a response is received from the AJAX request, a few assertions are made confirming:
|
||||
收到 AJAX 请求的响应之后,会有几项断言确认:
|
||||
|
||||
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.
|
||||
1. 响应状态是 `200`
|
||||
2. `<span id='name'></span>` 元素的文本是 `'Marco'`
|
||||
3. `<span id='surname'></span>` 元素的文本是 `'Polo'`
|
||||
4. 有 `1` 个 `<span id='dates'></span>` 元素。
|
||||
|
||||
Finally, the `done` callback is invoked, which is needed due to the asynchronous test.
|
||||
最后,执行 `done`,这是异步测试所必需的。
|
||||
|
||||
# --instructions--
|
||||
|
||||
Within `tests/2_functional-tests.js`, in the `'submit "surname" : "Colombo" - write your e2e test...'` test (`// #5`), automate filling-in and submitting the form:
|
||||
在 `tests/2_functional-tests.js` 中,`'submit "surname" : "Colombo" - write your e2e test...'` 测试(`// #5`),自动化填入和提交表单:
|
||||
|
||||
1. Fill in the form
|
||||
2. Submit it pressing `'submit'` button.
|
||||
1. 填写表单
|
||||
2. 点击 `'submit'` 按钮提交表单
|
||||
|
||||
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`
|
||||
1. 断言状态是正常的 `200`
|
||||
2. 断言元素 `span#name` 中的文本是 `'Cristoforo'`
|
||||
3. 断言元素 `span#surname` 元素中的文本是 `'Colombo'`
|
||||
4. 断言有 `span#dates` 元素,它们的计数是 `1`
|
||||
|
||||
Do not forget to remove the `assert.fail()` call.
|
||||
不要忘记删除 `assert.fail()` 调用。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
应通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -67,7 +67,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should assert that the headless browser request succeeded.
|
||||
应该断言无头浏览器请求成功。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -81,7 +81,7 @@ You should assert that the headless browser request succeeded.
|
||||
);
|
||||
```
|
||||
|
||||
You should assert that the text inside the element 'span#name' is 'Cristoforo'.
|
||||
应该断言元素 “span#name” 中的文字为 “Cristoforo”。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -97,7 +97,7 @@ You should assert that the text inside the element 'span#name' is 'Cristoforo'.
|
||||
);
|
||||
```
|
||||
|
||||
You should assert that the text inside the element 'span#surname' is 'Colombo'.
|
||||
应该断言元素 “span#surname” 中的文字为 “Colombo”。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -113,7 +113,7 @@ You should assert that the text inside the element 'span#surname' is 'Colombo'.
|
||||
);
|
||||
```
|
||||
|
||||
You should assert that the element 'span#dates' exist and its count is 1.
|
||||
应该断言元素 “span#dates” 存在,且它的值为 1。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,45 +1,45 @@
|
||||
---
|
||||
id: 587d824f367417b2b2512c5c
|
||||
title: Simulate Actions Using a Headless Browser
|
||||
title: 使用无头浏览器模拟操作
|
||||
challengeType: 2
|
||||
dashedName: simulate-actions-using-a-headless-browser
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
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/).
|
||||
请注意,本项目在[这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
In the next challenges we are going to simulate the human interaction with a page using a device called 'Headless Browser'.
|
||||
在接下来的挑战中,我们将使用名为 “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.
|
||||
无头浏览器是没有图形用户界面的 Web 浏览器。 这种工具对于测试网页特别有用,因为它能够以与浏览器相同的方式呈现和理解 HTML、CSS 和 JavaScript。
|
||||
|
||||
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.
|
||||
针对这些挑战,我们使用 Zombie.JS。 它是一个轻量级浏览器,完全基于 JS,而不需要额外的二进制文件来安装。 这个功能使我们可以在 Repl.it 等环境中使用它。 还有许多其他(更强大的)选择。
|
||||
|
||||
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.
|
||||
Mocha 允许你在实际测试之前准备一些代码运行的基础。 这可能有助于例如在数据库中创建项目,用于连续测试。
|
||||
|
||||
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.
|
||||
使用无头浏览器,在进行实际测试之前,我们需要**访问**我们将要检查的页面。 `suiteSetup` “hook” 仅在套件启动时执行。 其他不同的钩子类型可以在每次测试之前、每次测试之后或者在套件的末尾执行。 更多信息请参阅 Mocha 文档。
|
||||
|
||||
# --instructions--
|
||||
|
||||
Within `tests/2_functional-tests.js`, immediately after the `Browser` declaration, add your project URL to the `site` property of the variable:
|
||||
在 `tests/2_functional-tests.js`中,紧接着 `Browser` 声明之后,将你的项目 URL 添加到变量的 `site` 属性:
|
||||
|
||||
```js
|
||||
Browser.site = 'https://sincere-cone.gomix.me'; // Your URL here
|
||||
```
|
||||
|
||||
If you are testing on a local environment replace the line above with
|
||||
如果你在本地环境中测试,则替换上面的代码为:
|
||||
|
||||
```js
|
||||
Browser.localhost('example.com', process.env.PORT || 3000);
|
||||
```
|
||||
|
||||
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:
|
||||
在 `tests/2_functional-tests.js` 中,在 `'Functional Tests with Zombie.js'` 套件的底部,使用以下代码实例化一个新的 `Browser` 对象:
|
||||
|
||||
```js
|
||||
const browser = new Browser();
|
||||
```
|
||||
|
||||
Then, use the `suiteSetup` hook to direct the `browser` to the `/` route with the following code:
|
||||
然后,通过以下代码,使用 `suiteSetup` 钩子把 `browser` 指向 `/` 路由:
|
||||
|
||||
```js
|
||||
suiteSetup(function(done) {
|
||||
@@ -49,7 +49,7 @@ suiteSetup(function(done) {
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
应通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824b367417b2b2512c49
|
||||
title: Test for Truthiness
|
||||
title: 测试真实性
|
||||
challengeType: 2
|
||||
forumTopicId: 301596
|
||||
dashedName: test-for-truthiness
|
||||
@@ -8,9 +8,9 @@ dashedName: test-for-truthiness
|
||||
|
||||
# --description--
|
||||
|
||||
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/).
|
||||
请注意,本项目在[这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
`isTrue()` will test for the boolean value `true` and `isNotTrue()` will pass when given anything but the boolean value of `true`.
|
||||
`isTrue()` 仅当给出的值为 Boolean 的 `true` 时可以通过测试;`isNotTrue()` 则会在给出除 `true` 以外的值时通过测试。
|
||||
|
||||
```js
|
||||
assert.isTrue(true, 'this will pass with the boolean value true');
|
||||
@@ -18,15 +18,15 @@ 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()` and `isNotFalse()` also exist, and behave similarly to their true counterparts except they look for the boolean value of `false`.
|
||||
`isFalse()` 和 `isNotFalse()` 同样存在,与上面提到的两个方法类似,只不过它们针对值为 `false` 的布尔值。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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.
|
||||
在 `tests/1_unit-tests.js` 中,`Basic Assertions` 套件中标注为 `#4` 的测试下,修改每个 `assert` 为 `assert.isTrue` 或 `assert.isNotTrue`,通过测试(结果应为 `true`)。 不要修改传入断言的参数。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
应通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -40,7 +40,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the first assertion - `isTrue` vs. `isNotTrue`.
|
||||
应该为第一个断言选择正确的方法:`isTrue` 或 `isNotTrue`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -54,7 +54,7 @@ You should choose the correct method for the first assertion - `isTrue` vs. `isN
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the second assertion - `isTrue` vs. `isNotTrue`.
|
||||
应该为第二个断言选择正确的方法:`isTrue` 或 `isNotTrue`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -72,7 +72,7 @@ You should choose the correct method for the second assertion - `isTrue` vs. `is
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the third assertion - `isTrue` vs. `isNotTrue`.
|
||||
应该为第三个断言选择正确的方法:`isTrue` 或 `isNotTrue`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824d367417b2b2512c53
|
||||
title: Test if a String Contains a Substring
|
||||
title: 测试字符串是否包含子字符串
|
||||
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--
|
||||
|
||||
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/).
|
||||
请注意,本项目在[这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
`include()` and `notInclude()` work for strings too! `include()` asserts that the actual string contains the expected substring.
|
||||
`include()` 和 `notInclude()` 同样可以用于字符串。 `include()` 用于断言字符串中包含某个子字符串。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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.
|
||||
在 `tests/1_unit-tests.js` 中,`Strings` 套件里标有 `#14` 的测试下,将每个 `assert` 改成 `assert.include` 或 `assert.notInclude` 方法,通过测试(结果应该返回 `true`)。 不要修改传给断言的参数。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
应通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the first assertion - `include` vs. `notInclude`.
|
||||
应该为第一个断言选择正确的方法:`include` 或 `notInclude`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +50,7 @@ You should choose the correct method for the first assertion - `include` vs. `no
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the second assertion - `include` vs. `notInclude`.
|
||||
应该为第二个断言选择正确的方法:`include` 或 `notInclude`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824c367417b2b2512c4f
|
||||
title: Test if a Value Falls within a Specific Range
|
||||
title: 测试某个值是否在特定范围内
|
||||
challengeType: 2
|
||||
forumTopicId: 301598
|
||||
dashedName: test-if-a-value-falls-within-a-specific-range
|
||||
@@ -8,23 +8,23 @@ dashedName: test-if-a-value-falls-within-a-specific-range
|
||||
|
||||
# --description--
|
||||
|
||||
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/).
|
||||
请注意,本项目在 [这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 的基础上进行开发。 你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
```javascript
|
||||
.approximately(actual, expected, delta, [message])
|
||||
```
|
||||
|
||||
Asserts that the `actual` is equal to `expected`, to within a +/- `delta` range.
|
||||
断言 `actual` 等于 `expected`,在 +/- `delta` 的范围内。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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`).
|
||||
在 `tests/1_unit-tests.js` 中,在 `Comparisons` 套件里标有 `#10` 的测试中,将每个 `assert` 改成 `assert.approximately`,让测试通过(结果应该返回 `true`)。
|
||||
|
||||
Choose the minimum range (3rd parameter) to make the test always pass. It should be less than 1.
|
||||
选择最小范围(第三个参数)来通过所有测试。 它应该小于 1。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
不应有未通过的测试
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -38,7 +38,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct range for the first assertion - `approximately(actual, expected, range)`.
|
||||
应该为第一个断言选择正确的范围——`approximately(actual, expected, range)`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -57,7 +57,7 @@ You should choose the correct range for the first assertion - `approximately(act
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct range for the second assertion - `approximately(actual, expected, range)`.
|
||||
应该为第二个断言选择正确的范围——`approximately(actual, expected, range)`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824d367417b2b2512c52
|
||||
title: Test if a Value is a String
|
||||
title: 测试某个值是否为字符串
|
||||
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--
|
||||
|
||||
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/).
|
||||
请注意,本项目在[这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
`isString` or `isNotString` asserts that the actual value is a string.
|
||||
`isString` 或 `isNotString` 断言一个值是否为字符串。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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.
|
||||
在 `tests/1_unit-tests.js` 中,`Strings` 套件里标有 `#13` 的测试下,将每个 `assert` 改成 `assert.isString` 或 `assert.isNotString` 方法,通过测试(结果应该返回 `true`)。 不要修改传给断言的参数。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
应通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the first assertion - `isString` vs. `isNotString`.
|
||||
应该为第一个断言选择正确的方法:`isString` 或 `isNotString`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +50,7 @@ You should choose the correct method for the first assertion - `isString` vs. `i
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the second assertion - `isString` vs. `isNotString`.
|
||||
应该为第二个断言选择正确的方法:`isString` 或 `isNotString`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -68,7 +68,7 @@ You should choose the correct method for the second assertion - `isString` vs. `
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the third assertion - `isString` vs. `isNotString`.
|
||||
应该为第三个断言选择正确的方法:`isString` 或 `isNotString`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824d367417b2b2512c50
|
||||
title: Test if a Value is an Array
|
||||
title: 测试某个值是否为数组
|
||||
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--
|
||||
|
||||
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/).
|
||||
请注意,本项目在[这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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.
|
||||
在 `tests/1_unit-tests.js` 中,`Arrays` 套件里标有 `#11` 的测试下,将每个 `assert` 改成 `assert.isArray` 或 `assert.isNotArray` 方法,通过测试(结果应该返回 `true`)。 不要改变传入断言的参数。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
不应有未通过的测试
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -30,7 +30,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the first assertion - `isArray` vs. `isNotArray`.
|
||||
请选择正确的断言——`isArray` 或 `isNotArray`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -48,7 +48,7 @@ You should choose the correct method for the first assertion - `isArray` vs. `is
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the second assertion - `isArray` vs. `isNotArray`.
|
||||
请选择正确的断言——`isArray` 或 `isNotArray`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824e367417b2b2512c56
|
||||
title: Test if a Value is of a Specific Data Structure Type
|
||||
title: 测试值是否为特定数据结构类型
|
||||
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--
|
||||
|
||||
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/).
|
||||
请注意,本项目在[这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
`#typeOf` asserts that value's type is the given string, as determined by `Object.prototype.toString`.
|
||||
`#typeOf` 断言一个值的类型符合给定的类型,这个类型与 `Object.prototype.toString` 一致。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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.
|
||||
在 `tests/1_unit-tests.js` 中,`Objects` 套件里标有 `#17` 的测试下,将每个 `assert` 改成 `assert.typeOf` 或 `assert.notTypeOf` 方法,通过测试(结果应该返回 `true`)。 不要修改传给断言的参数。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
应通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the first assertion - `typeOf` vs. `notTypeOf`.
|
||||
应该为第一个断言选择正确的方法:`typeOf` 或 `notTypeOf`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +50,7 @@ You should choose the correct method for the first assertion - `typeOf` vs. `not
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the second assertion - `typeOf` vs. `notTypeOf`.
|
||||
应该为第二个断言选择正确的方法:`typeOf` 或 `notTypeOf`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -68,7 +68,7 @@ You should choose the correct method for the second assertion - `typeOf` vs. `no
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the third assertion - `typeOf` vs. `notTypeOf`.
|
||||
应该为第三个断言选择正确的方法:`typeOf` 或 `notTypeOf`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -86,7 +86,7 @@ You should choose the correct method for the third assertion - `typeOf` vs. `not
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the fourth assertion - `typeOf` vs. `notTypeOf`.
|
||||
应该为第四个断言选择正确的方法:`typeOf` 或 `notTypeOf`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -104,7 +104,7 @@ You should choose the correct method for the fourth assertion - `typeOf` vs. `no
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the fifth assertion - `typeOf` vs. `notTypeOf`.
|
||||
应该为第五个断言选择正确的方法:`typeOf` 或 `notTypeOf`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824b367417b2b2512c47
|
||||
title: Test if a Variable or Function is Defined
|
||||
title: 测试变量或函数是否已定义
|
||||
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--
|
||||
|
||||
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/).
|
||||
请注意,本项目在[这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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.
|
||||
在 `tests/1_unit-tests.js` 中,`Basic Assertions` 套件中标注为 `#2` 的测试下,修改每个 `assert` 为 `assert.isDefined()` 或 `assert.isUndefined()`,通过测试(结果应为 `true`)。 不要修改传给断言的参数。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
应通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -30,7 +30,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the first assertion - `isDefined` vs. `isUndefined`.
|
||||
应该为第一个断言选择正确的方法:`isDefined` 或 `isUndefined`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -48,7 +48,7 @@ You should choose the correct method for the first assertion - `isDefined` vs. `
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the second assertion - `isDefined` vs. `isUndefined`.
|
||||
应该为第二个断言选择正确的方法:`isDefined` 或 `isUndefined`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -66,7 +66,7 @@ You should choose the correct method for the second assertion - `isDefined` vs.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the third assertion - `isDefined` vs. `isUndefined`.
|
||||
应该为第三个断言选择正确的方法:`isDefined` 或 `isUndefined`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824d367417b2b2512c51
|
||||
title: Test if an Array Contains an Item
|
||||
title: 测试数组是否包含项目
|
||||
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--
|
||||
|
||||
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/).
|
||||
请注意,本项目在[这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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.
|
||||
在 `tests/1_unit-tests.js` 中,`Arrays` 套件里标有 `#12` 的测试下,将每个 `assert` 改成 `assert.include` 或 `assert.notInclude` 方法,通过测试(结果应该返回 `true`)。 不要修改传给断言的参数。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
应通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -30,7 +30,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the first assertion - `include` vs. `notInclude`.
|
||||
应该为第一个断言选择正确的方法:`include` 或 `notInclude`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -48,7 +48,7 @@ You should choose the correct method for the first assertion - `include` vs. `no
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the second assertion - `include` vs. `notInclude`.
|
||||
应该为第二个断言选择正确的方法:`include` 或 `notInclude`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824e367417b2b2512c55
|
||||
title: Test if an Object has a Property
|
||||
title: 测试对象是否具有某个属性
|
||||
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--
|
||||
|
||||
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/).
|
||||
请注意,本项目在[这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
`property` asserts that the actual object has a given property.
|
||||
`property` 断言一个对象含有给定属性。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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.
|
||||
在 `tests/1_unit-tests.js` 中,`Objects` 套件里标有 `#16` 的测试下,将每个 `assert` 改成 `assert.property` 或 `assert.notProperty` 方法,通过测试(结果应该返回 `true`)。 不要修改传给断言的参数。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
应通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the first assertion - `property` vs. `notProperty`.
|
||||
应该为第一个断言选择正确的方法:`property` 或 `notProperty`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +50,7 @@ You should choose the correct method for the first assertion - `property` vs. `n
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the second assertion - `property` vs. `notProperty`.
|
||||
应该为第二个断言选择正确的方法:`property` 或 `notProperty`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -68,7 +68,7 @@ You should choose the correct method for the second assertion - `property` vs. `
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the third assertion - `property` vs. `notProperty`.
|
||||
应该为第三个断言选择正确的方法:`property` 或 `notProperty`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824e367417b2b2512c57
|
||||
title: Test if an Object is an Instance of a Constructor
|
||||
title: 测试对象是否是构造函数的实例
|
||||
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--
|
||||
|
||||
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/).
|
||||
请注意,本项目在[这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
`#instanceOf` asserts that an object is an instance of a constructor.
|
||||
`#instanceOf` 断言一个对象是一个构造器的实例。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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.
|
||||
在 `tests/1_unit-tests.js` 中,`Objects` 套件里标有 `#18` 的测试下,将每个 `assert` 改成 `assert.instanceOf` 或 `assert.notInstanceOf` 方法,通过测试(结果应该返回 `true`)。 不要修改传给断言的参数。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
应通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the first assertion - `instanceOf` vs. `notInstanceOf`.
|
||||
应该为第一个断言选择正确的方法:`instanceOf` 或 `notInstanceOf`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +50,7 @@ You should choose the correct method for the first assertion - `instanceOf` vs.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the second assertion - `instanceOf` vs. `notInstanceOf`.
|
||||
应该为第二个断言选择正确的方法:`instanceOf` 或 `notInstanceOf`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -68,7 +68,7 @@ You should choose the correct method for the second assertion - `instanceOf` vs.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the third assertion - `instanceOf` vs. `notInstanceOf`.
|
||||
应该为第三个断言选择正确的方法:`instanceOf` 或 `notInstanceOf`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -86,7 +86,7 @@ You should choose the correct method for the third assertion - `instanceOf` vs.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the fourth assertion - `instanceOf` vs. `notInstanceOf`.
|
||||
应该为第四个断言选择正确的方法:`instanceOf` 或 `notInstanceOf`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824c367417b2b2512c4e
|
||||
title: Test if One Value is Below or At Least as Large as Another
|
||||
title: 测试一个值是否小于或等于另一个值
|
||||
challengeType: 2
|
||||
forumTopicId: 301606
|
||||
dashedName: test-if-one-value-is-below-or-at-least-as-large-as-another
|
||||
@@ -8,15 +8,15 @@ dashedName: test-if-one-value-is-below-or-at-least-as-large-as-another
|
||||
|
||||
# --description--
|
||||
|
||||
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/).
|
||||
请注意,本项目在[这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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.
|
||||
在 `tests/1_unit-tests.js` 中,在 `Comparisons` 套件里标有 `#9` 的测试中,将每个 `assert` 改成 `assert.isBelow` 或 `assert.isAtLeast` 方法,让测试通过(结果应该返回 `true`)。 不要修改传给断言的参数。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
应通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -30,7 +30,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the first assertion - `isBelow` vs. `isAtLeast`.
|
||||
应该为第一个断言选择正确的方法:`isBelow` 或 `isAtLeast`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -48,7 +48,7 @@ You should choose the correct method for the first assertion - `isBelow` vs. `is
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the second assertion - `isBelow` vs. `isAtLeast`.
|
||||
应该为第二个断言选择正确的方法:`isBelow` 或 `isAtLeast`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -66,7 +66,7 @@ You should choose the correct method for the second assertion - `isBelow` vs. `i
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the third assertion - `isBelow` vs. `isAtLeast`.
|
||||
应该为第三个断言选择正确的方法:`isBelow` 或 `isAtLeast`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -80,7 +80,7 @@ You should choose the correct method for the third assertion - `isBelow` vs. `is
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the fourth assertion - `isBelow` vs. `isAtLeast`.
|
||||
应该为第四个断言选择正确的方法:`isBelow` 或 `isAtLeast`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824b367417b2b2512c48
|
||||
title: Use Assert.isOK and Assert.isNotOK
|
||||
title: 使用 Assert.isOk() 和 Assert.isNotOK()
|
||||
challengeType: 2
|
||||
forumTopicId: 301607
|
||||
dashedName: use-assert-isok-and-assert-isnotok
|
||||
@@ -8,19 +8,19 @@ dashedName: use-assert-isok-and-assert-isnotok
|
||||
|
||||
# --description--
|
||||
|
||||
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/).
|
||||
请注意,本项目在[这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
`isOk()` will test for a truthy value, and `isNotOk()` will test for a falsy value.
|
||||
`isOk()` 用来测试值是否为真值,`isNotOk()` 用来测试值是否为假值。
|
||||
|
||||
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.
|
||||
可以在[过滤数组中的假值](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/falsy-bouncer)这个挑战中了解更多关于真值和假值的信息。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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.
|
||||
在 `tests/1_unit-tests.js` 中,`Basic Assertions` 套件中标注为 `#3` 的测试下,修改每个 `assert` 为 `assert.isOk()` 或 `assert.isNotOk()`,通过测试(结果应为 `true`)。 不要修改传入断言的参数。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
应通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -34,7 +34,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the first assertion - `isOk` vs. `isNotOk`.
|
||||
应该第一个断言选择正确的方法:`isOk` 或 `isNotOk`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -48,7 +48,7 @@ You should choose the correct method for the first assertion - `isOk` vs. `isNot
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the second assertion - `isOk` vs. `isNotOk`.
|
||||
应该第二个断言选择正确的方法:`isOk` 或 `isNotOk`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -62,7 +62,7 @@ You should choose the correct method for the second assertion - `isOk` vs. `isNo
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the third assertion - `isOk` vs. `isNotOk`.
|
||||
应该第三个断言选择正确的方法:`isOk` 或 `isNotOk`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824d367417b2b2512c54
|
||||
title: Use Regular Expressions to Test a String
|
||||
title: 使用正则表达式测试字符串
|
||||
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--
|
||||
|
||||
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/).
|
||||
请注意,本项目在[这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
`match()` asserts that the actual value matches the second argument regular expression.
|
||||
`match()` 断言一个值匹配一个正则表达式(第二个参数)。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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.
|
||||
在 `tests/1_unit-tests.js` 中,`Strings` 套件里标有 `#15` 的测试下,将每个 `assert` 改成 `assert.match` 或 `assert.notMatch` 方法,通过测试(结果应该返回 `true`)。 不要修改传给断言的参数。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
应通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the first assertion - `match` vs. `notMatch`.
|
||||
应该为第一个断言选择正确的方法:`match` 或 `notMatch`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +50,7 @@ You should choose the correct method for the first assertion - `match` vs. `notM
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the second assertion - `match` vs. `notMatch`.
|
||||
应该为第二个断言选择正确的方法:`match` 或 `notMatch`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824b367417b2b2512c4a
|
||||
title: Use the Double Equals to Assert Equality
|
||||
title: 用两个等号断言相等
|
||||
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--
|
||||
|
||||
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/).
|
||||
请注意,本项目在[这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
`equal()` compares objects using `==`.
|
||||
`equal()` 使用 `==` 比较对象。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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.
|
||||
在 `tests/1_unit-tests.js` 中,在 `Equality` 套件里标有 `#5` 的测试里,将每个 `assert` 改为 `assert.equal` 或 `assert.notEqual`,通过测试(应该返回 `true`)。 不要修改传给断言的参数。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
应通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the first assertion - `equal` vs. `notEqual`.
|
||||
应该为第一个断言选择正确的方法:`equal` 或 `notEqual`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +50,7 @@ You should choose the correct method for the first assertion - `equal` vs. `notE
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the second assertion - `equal` vs. `notEqual`.
|
||||
应该为第二个断言选择正确的方法:`equal` 或 `notEqual`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -68,7 +68,7 @@ You should choose the correct method for the second assertion - `equal` vs. `not
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the third assertion - `equal` vs. `notEqual`.
|
||||
应该为第三个断言选择正确的方法:`equal` 或 `notEqual`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -86,7 +86,7 @@ You should choose the correct method for the third assertion - `equal` vs. `notE
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the fourth assertion - `equal` vs. `notEqual`.
|
||||
应该为第四个断言选择正确的方法:`equal` 或 `notEqual`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d824b367417b2b2512c4b
|
||||
title: Use the Triple Equals to Assert Strict Equality
|
||||
title: 用三个等号断言严格相等
|
||||
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--
|
||||
|
||||
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/).
|
||||
请注意,本项目在[这个 Repl.it 项目](https://repl.it/github/freeCodeCamp/boilerplate-mochachai)的基础上进行开发。你也可以从 [GitHub](https://repl.it/github/freeCodeCamp/boilerplate-mochachai) 上克隆。
|
||||
|
||||
`strictEqual()` compares objects using `===`.
|
||||
`strictEqual()` 使用 `===` 比较对象。
|
||||
|
||||
# --instructions--
|
||||
|
||||
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.
|
||||
在 `tests/1_unit-tests.js` 中,在 `Equality` 套件里标有 `#6` 的测试下,将每个 `assert` 改为 `assert.strictEqual` 或 `assert.notStrictEqual`,让测试通过(应该返回 `true`)。 不要修改传给断言的参数。
|
||||
|
||||
# --hints--
|
||||
|
||||
All tests should pass.
|
||||
应通过所有测试。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -32,7 +32,7 @@ All tests should pass.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the first assertion - `strictEqual` vs. `notStrictEqual`.
|
||||
应该为第一个断言选择正确的方法:`strictEqual` 或 `notStrictEqual`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -50,7 +50,7 @@ You should choose the correct method for the first assertion - `strictEqual` vs.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the second assertion - `strictEqual` vs. `notStrictEqual`.
|
||||
应该为第二个断言选择正确的方法:`strictEqual` 或 `notStrictEqual`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -64,7 +64,7 @@ You should choose the correct method for the second assertion - `strictEqual` vs
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the third assertion - `strictEqual` vs. `notStrictEqual`.
|
||||
应该为第三个断言选择正确的方法:`strictEqual` 或 `notStrictEqual`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
@@ -82,7 +82,7 @@ You should choose the correct method for the third assertion - `strictEqual` vs.
|
||||
);
|
||||
```
|
||||
|
||||
You should choose the correct method for the fourth assertion - `strictEqual` vs. `notStrictEqual`.
|
||||
应该为第四个断言选择正确的方法:`strictEqual` 或 `notStrictEqual`。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
Reference in New Issue
Block a user