chore(i18n,learn): processed translations (#44851)
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
---
|
||||
id: 587d824c367417b2b2512c4c
|
||||
title: .deepEqual と .notDeepEqual で deep equality をアサートする
|
||||
challengeType: 2
|
||||
forumTopicId: 301587
|
||||
dashedName: assert-deep-equality-with--deepequal-and--notdeepequal
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
`deepEqual()` は、2 つのオブジェクトが deep equal であることをアサートします。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/1_unit-tests.js` の中の、`Equality` スイート内の `#7` に分類されたテストにおいて、テストを合格にする (`true` と評価する必要があります) ために、それぞれの `assert` を `assert.deepEqual` または `assert.notDeepEqual` に変更してください。 アサートに渡された引数を変更しないでください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=6').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
最初のアサーションに、正しいメソッドを選ぶ必要があります - `deepEqual` もしくは `notDeepEqual` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=6').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[0].method,
|
||||
'deepEqual',
|
||||
'The order of the keys does not matter'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
2 番目のアサーションに、正しいメソッドを選ぶ必要があります - `deepEqual` もしくは `notDeepEqual` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=6').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[1].method,
|
||||
'notDeepEqual',
|
||||
'The position of elements within an array does matter'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,109 @@
|
||||
---
|
||||
id: 587d824c367417b2b2512c4d
|
||||
title: 2 つの要素のプロパティを比較する
|
||||
challengeType: 2
|
||||
forumTopicId: 301588
|
||||
dashedName: compare-the-properties-of-two-elements
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/1_unit-tests.js` の中の、`Comparisons` スイート内の `#8` に分類されたテストにおいて、テストを合格にする (`true` と評価する必要があります) ために、それぞれの `assert` を `assert.isAbove` または `assert.isAtMost` に変更してください。 アサートに渡された引数を変更しないでください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=7').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
最初のアサーションに、正しいメソッドを選ぶ必要があります - `isAbove` もしくは `isAtMost` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=7').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[0].method,
|
||||
'isAtMost',
|
||||
'5 is at most (<=) 5'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
2 番目のアサーションに、正しいメソッドを選ぶ必要があります- `isAbove` もしくは `isAtMost` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=7').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[1].method, 'isAbove', '1 is greater than 0');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
3 番目のアサーションに、正しいメソッドを選ぶ必要があります- `isAbove` もしくは `isAtMost` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=7').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[2].method,
|
||||
'isAbove',
|
||||
'Math.PI = 3.14159265 is greater than 3'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
4 番目のアサーションに、正しいメソッドを選ぶ必要があります - `isAbove` もしくは `isAtMost` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=7').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[3].method,
|
||||
'isAtMost',
|
||||
'1 - Math.random() is > 0 and <= 1. It is atMost 1 !'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: 587d824a367417b2b2512c46
|
||||
title: JavaScript アサーションがどのように機能するかを学ぶ
|
||||
challengeType: 2
|
||||
forumTopicId: 301589
|
||||
dashedName: learn-how-javascript-assertions-work
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
これらのチャレンジに取り組むにあたり、以下の方法のうち 1 つを用いてコードを記述します。
|
||||
|
||||
- [GitHub レポジトリ](https://github.com/freeCodeCamp/boilerplate-mochachai/)をクローンし、ローカル環境でチャレンジを完了させる。
|
||||
- [Replit 始動プロジェクト](https://replit.com/github/freeCodeCamp/boilerplate-mochachai)を使用してチャレンジを完了させる。
|
||||
- 使い慣れたサイトビルダーを使用してプロジェクトを完了させる。 必ず GitHub リポジトリのすべてのファイルを取り込む。
|
||||
|
||||
完了したら、プロジェクトの動作デモをどこか公開の場にホストしてください。 そして、`Solution Link` フィールドでデモへの URL を送信してください。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/1_unit-tests.js` の中の、`Basic Assertions` スイート内の `#1` に分類されたテストにおいて、テストを合格にする (`true` と評価する必要があります) ために、それぞれの `assert` を `assert.isNull` または `assert.isNotNull` に変更してください。 アサートに渡された引数を変更しないでください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=0').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
最初のアサーションに対して、正しいメソッドを選ぶ必要があります - `isNull` もしくは `isNotNull` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=0').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[0].method, 'isNull', 'Null is null');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
2 番目のアサーションに対して、正しいメソッドを選ぶ必要があります- `isNull` もしくは `isNotNull` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=0').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[1].method, 'isNotNull', '1 is not null');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,148 @@
|
||||
---
|
||||
id: 587d824f367417b2b2512c5a
|
||||
title: Chai-HTTP を使用して API レスポンスで機能テストを実行するⅢ - PUT メソッド
|
||||
challengeType: 2
|
||||
forumTopicId: 301590
|
||||
dashedName: run-functional-tests-on-an-api-response-using-chai-http-iii---put-method
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
`PUT` リクエストをテストする時、一緒にデータを送信することがよくあります。 `PUT` リクエストに含まれるデータは、リクエストボディと呼ばれます。
|
||||
|
||||
`PUT` リクエストと JSON オブジェクトを `'/travellers'` エンドポイントへ送信するために、`chai-http` プラグインの `put` メソッドと `send` メソッドを使用することができます。
|
||||
|
||||
```js
|
||||
chai
|
||||
.request(server)
|
||||
.put('/travellers')
|
||||
.send({
|
||||
"surname": [last name of a traveller of the past]
|
||||
})
|
||||
...
|
||||
```
|
||||
|
||||
するとルートは次のように応答します。
|
||||
|
||||
```json
|
||||
{
|
||||
"name": [first name],
|
||||
"surname": [last name],
|
||||
"dates": [birth - death years]
|
||||
}
|
||||
```
|
||||
|
||||
`'/travellers'` エンドポイントへの異なるレスポンスについては、サーバーのコードを参照してください。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/2_functional-tests.js` 内で、`'Send {surname: "Colombo"}'` テスト (`// #3`) を変更し、`put` メソッドと `send` メソッドを使用して `'/travellers'` エンドポイントをテストしてください。
|
||||
|
||||
PUT リクエストで、次の JSON オブジェクトを送信してください。
|
||||
|
||||
```json
|
||||
{
|
||||
"surname": "Colombo"
|
||||
}
|
||||
```
|
||||
|
||||
`request.end` コールバック内で、以下を確認してください。
|
||||
|
||||
1. `status` は、`200` でなければなりません。
|
||||
2. `type` は、`application/json` でなければなりません。
|
||||
3. `body.name` は、`Cristoforo` でなければなりません。
|
||||
4. `body.surname` は、`Colombo` でなければなりません。
|
||||
|
||||
上記のアサーション順序に従ってください (この順序を想定しています)。 また、完了したら必ず `assert.fail()` を削除してください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=2').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
`res.status` が 200 かどうかをテストする必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=2').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[0].method, 'equal');
|
||||
assert.equal(data.assertions[0].args[0], 'res.status');
|
||||
assert.equal(data.assertions[0].args[1], '200');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
`res.type` が `'application/json'` かどうかをテストする必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=2').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[1].method, 'equal');
|
||||
assert.equal(data.assertions[1].args[0], 'res.type');
|
||||
assert.match(data.assertions[1].args[1], /('|")application\/json\1/);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
`res.body.name` が `'Cristoforo'` かどうかをテストする必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=2').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[2].method, 'equal');
|
||||
assert.equal(data.assertions[2].args[0], 'res.body.name');
|
||||
assert.match(data.assertions[2].args[1], /('|")Cristoforo\1/);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
`res.body.surname` が `'Colombo'` かどうかをテストする必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=2').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[3].method, 'equal');
|
||||
assert.equal(data.assertions[3].args[0], 'res.body.surname');
|
||||
assert.match(data.assertions[3].args[1], /('|")Colombo\1/);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,126 @@
|
||||
---
|
||||
id: 587d824f367417b2b2512c5b
|
||||
title: Chai-HTTP を使用して API レスポンスで機能テストを実行する Ⅳ - PUT メソッド
|
||||
challengeType: 2
|
||||
forumTopicId: 301591
|
||||
dashedName: run-functional-tests-on-an-api-response-using-chai-http-iv---put-method
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
この演習は、前回のものと似ています。
|
||||
|
||||
`PUT` リクエストをテストする方法が分かったので、テストを最初から実行してみましょう。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/2_functional-tests.js` 内で、`'Send {surname: "da Verrazzano"}'` テスト (`// #4`) を変更し、`put` メソッドと `send` メソッドを使用して `'/travellers'` エンドポイントをテストしてください。
|
||||
|
||||
PUT リクエストで、以下の JSON オブジェクトを送信してください。
|
||||
|
||||
```json
|
||||
{
|
||||
"surname": "da Verrazzano"
|
||||
}
|
||||
```
|
||||
|
||||
`request.end` コールバック内で、以下を確認してください。
|
||||
|
||||
1. `status` は、`200` でなければなりません。
|
||||
2. `type` は、 `application/json` でなければなりません。
|
||||
3. `body.name` は、`Giovanni` でなければなりません。
|
||||
4. `body.surname` は、`da Verrazzano` でなければなりません。
|
||||
|
||||
上記のアサーション順序に従ってください (この順序を想定しています)。 また、完了したら必ず `assert.fail()` を削除してください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=3').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
`res.status` が 200 かどうかをテストする必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=3').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[0].method, 'equal');
|
||||
assert.equal(data.assertions[0].args[0], 'res.status');
|
||||
assert.equal(data.assertions[0].args[1], '200');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
`res.type` が `'application/json'` かどうかをテストする必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=3').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[1].method, 'equal');
|
||||
assert.equal(data.assertions[1].args[0], 'res.type');
|
||||
assert.match(data.assertions[1].args[1], /('|")application\/json\1/);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
`res.body.name` が `'Giovanni'` かどうかをテストする必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=3').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[2].method, 'equal');
|
||||
assert.equal(data.assertions[2].args[0], 'res.body.name');
|
||||
assert.match(data.assertions[2].args[1], /('|")Giovanni\1/);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
`res.body.surname` が `'da Verrazzano'` かどうかをテストする必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=3').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[3].method, 'equal');
|
||||
assert.equal(data.assertions[3].args[0], 'res.body.surname');
|
||||
assert.match(data.assertions[3].args[1], /('|")da Verrazzano\1/);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: 587d824f367417b2b2512c59
|
||||
title: Chai-HTTPを使用して API エンドポイントで機能テストを実行するⅡ
|
||||
challengeType: 2
|
||||
forumTopicId: 301592
|
||||
dashedName: run-functional-tests-on-api-endpoints-using-chai-http-ii
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/2_functional-tests.js` 内で、`'Test GET /hello with your name'` テスト (`// #2`) を変更し、レスポンスの `status` と `text` をアサートしてテストに合格させてください。
|
||||
|
||||
ルートに `?name=<your_name>` を追加して名前を URL クエリとして送信してください。 エンドポイントは `'hello <your_name>'` で応答します。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=1').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
`res.status` == 200 をテストする必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=1').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[0].method, 'equal');
|
||||
assert.equal(data.assertions[0].args[0], 'res.status');
|
||||
assert.equal(data.assertions[0].args[1], '200');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
`res.text` == `'hello <your_name>'` をテストする必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=1').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[1].method, 'equal');
|
||||
assert.equal(data.assertions[1].args[0], 'res.text');
|
||||
assert.match(data.assertions[1].args[1], /hello [\w\d_-]/);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,100 @@
|
||||
---
|
||||
id: 587d824e367417b2b2512c58
|
||||
title: Chai-HTTP を使用して API エンドポイントの機能テストを実行する
|
||||
challengeType: 2
|
||||
forumTopicId: 301593
|
||||
dashedName: run-functional-tests-on-api-endpoints-using-chai-http
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
Mocha では、`chai-http` というプラグインを使用して API エンドポイントへの呼び出しのような非同期操作をテストできます。
|
||||
|
||||
`chai-http` を使用して `'GET /hello?name=[name] => "hello [name]"'` というスイートをテストする例を次に示します。
|
||||
|
||||
```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();
|
||||
});
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
テストでは、サーバーへ `GET` リクエストを送信し、名前を URL クエリ文字列 (`?name=John`) として指定します。 `end` メソッドのコールバック関数では、レスポンスオブジェクト (`res`) を受信します。レスポンスオブジェクトには `status` プロパティが含まれています。
|
||||
|
||||
最初の `assert.equal` は、ステータスが `200` に等しいかどうかを確認します。 2 番目の `assert.equal` は、レスポンス文字列 (`res.text`) が `"hello John"` と等しいことを確認します。
|
||||
|
||||
また、テストのコールバック関数の `done` パラメーターに注意してください。 非同期操作が完了したことを示すために、この関数をテストの最後に引数なしで呼び出す必要があります。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/2_functional-tests.js` 内で、`'Test GET /hello with no name'` テスト (`// #1`) を変更し、レスポンスの `status` と `text` をアサートしてテストに合格させてください。 アサートに渡された引数を変更しないでください。
|
||||
|
||||
URL クエリはなしとしてください。 名前の URL クエリがない場合、エンドポイントは `hello Guest` で応答します。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=0').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
`res.status` == 200 をテストする必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=0').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[0].method, 'equal');
|
||||
assert.equal(data.assertions[0].args[0], 'res.status');
|
||||
assert.equal(data.assertions[0].args[1], '200');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
`res.text` == `'hello Guest'` をテストする必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=0').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[1].method, 'equal');
|
||||
assert.equal(data.assertions[1].args[0], 'res.text');
|
||||
assert.match(data.assertions[1].args[1], /('|")hello Guest\1/);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,115 @@
|
||||
---
|
||||
id: 5f8884f4c46685731aabfc41
|
||||
title: ヘッドレスブラウザーを使用して機能テストを実行するⅡ
|
||||
challengeType: 2
|
||||
forumTopicId: 301594
|
||||
dashedName: run-functional-tests-using-a-headless-browser-ii
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/2_functional-tests.js` 内の `'Submit the surname "Vespucci" in the HTML form'` テスト (`// #5`) で、以下を自動化してください。
|
||||
|
||||
1. フォームに姓 `Vespucci` を入力します。
|
||||
2. 送信ボタンを押します。
|
||||
|
||||
`pressButton` コールバック内で以下を実行してください。
|
||||
|
||||
1. ステータスが OK `200` であることをアサートします。
|
||||
2. 要素 `span#name` 内のテキストが `'Amerigo'` であることをアサートします。
|
||||
3. 要素 `span#surname` 内のテキストが `'Vespucci'` であることをアサートします。
|
||||
4. 要素 `span#dates` が存在し、そのカウントが `1` であることをアサートします。
|
||||
|
||||
`assert.fail()` 呼び出しを削除することを忘れないでください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
ヘッドレスブラウザーのリクエストが成功したことをアサートする必要があります。
|
||||
|
||||
```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);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
要素 `span#name` 内のテキストが `'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);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
要素 `span#surname` 内のテキストが `'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);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
要素 `span#dates` が存在し、そのカウントが 1 であることをアサートする必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=6').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[3].method, 'browser.elements');
|
||||
assert.match(data.assertions[3].args[0], /('|")span#dates\1/);
|
||||
assert.equal(data.assertions[3].args[1], 1);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,148 @@
|
||||
---
|
||||
id: 587d8250367417b2b2512c5d
|
||||
title: ヘッドレスブラウザーを使用して機能テストを実行する
|
||||
challengeType: 2
|
||||
forumTopicId: 301595
|
||||
dashedName: run-functional-tests-using-a-headless-browser
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
ページに入力フォームがあります。 AJAX リクエストとして、`PUT /travellers` エンドポイントへデータを送信します。
|
||||
|
||||
リクエストが正常に完了すると、クライアントコードは、情報を含む `<div>` を、DOM へのレスポンスに追加します。
|
||||
|
||||
以下は、Zombie.js を使用してフォームとやり取りする方法の例です。
|
||||
|
||||
```js
|
||||
test('Submit the surname "Polo" in the HTML form', function (done) {
|
||||
browser.fill('surname', 'Polo').then(() => {
|
||||
browser.pressButton('submit', () => {
|
||||
browser.assert.success();
|
||||
browser.assert.text('span#name', 'Marco');
|
||||
browser.assert.text('span#surname', 'Polo');
|
||||
browser.assert.elements('span#dates', 1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
まず、`browser` オブジェクトの `fill` メソッドにより、フォームの `surname` フィールドに値 `'Polo'` を入力します。 `fill` は promise を返すので、そこから `then` でつなぎます。
|
||||
|
||||
`then` コールバック内で、`browser` オブジェクトの `pressButton` メソッドを使用して、フォームの `submit` イベントリスナーを呼び出します。 `pressButton` メソッドは非同期です。
|
||||
|
||||
その後、AJAX リクエストからレスポンスを受信すると、いくつかのアサーションが実行され、以下が確定します。
|
||||
|
||||
1. レスポンスのステータスは、`200` です。
|
||||
2. `<span id='name'></span>` 要素内のテキストは、`'Marco'` と一致します。
|
||||
3. `<span id='surname'></span>` 要素内のテキストは、`'Polo'` と一致します。
|
||||
4. `1` という内容の `<span id='dates'></span>` 要素があります。
|
||||
|
||||
最後に、`done` コールバックを呼び出します。これは非同期テストのために必要です。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/2_functional-tests.js` 内の `'Submit the surname "Colombo" in the HTML form'` テスト (`// #5`) で、以下を自動化してください。
|
||||
|
||||
1. フォームに姓 `Colombo` を入力します。
|
||||
2. 送信ボタンを押します。
|
||||
|
||||
`pressButton` コールバック内で以下を実行してください。
|
||||
|
||||
1. ステータスが OK `200` であることをアサートします。
|
||||
2. 要素 `span#name` 内のテキストが `'Cristoforo'` であることをアサートします。
|
||||
3. 要素 `span#surname` 内のテキストが `'Colombo'` であることをアサートします。
|
||||
4. 要素 `span#dates` が存在し、そのカウントが `1` であることをアサートします。
|
||||
|
||||
`assert.fail()` 呼び出しを削除することを忘れないでください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
ヘッドレスブラウザーのリクエストが成功したことをアサートする必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[0].method, 'browser.success');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
要素 `span#name` 内のテキストが `'Cristoforo'` であることをアサートする必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').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], /('|")Cristoforo\1/);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
要素 `span#surname` 内のテキストが `'Colombo'` であることをアサートする必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').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], /('|")Colombo\1/);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
要素 `span#dates` が存在し、カウントが 1 であることをアサートする必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=5').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[3].method, 'browser.elements');
|
||||
assert.match(data.assertions[3].args[0], /('|")span#dates\1/);
|
||||
assert.equal(data.assertions[3].args[1], 1);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: 587d824f367417b2b2512c5c
|
||||
title: ヘッドレスブラウザーを使用してアクションをシミュレートする
|
||||
challengeType: 2
|
||||
dashedName: simulate-actions-using-a-headless-browser
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
次のチャレンジでは、ヘッドレスブラウザーを使用してページと人間のやり取りをシミュレートします。
|
||||
|
||||
ヘッドレスブラウザーは、GUI を持たないウェブブラウザーです。 通常のブラウザーと同じように、HTML、CSS、および JavaScript をレンダーして解釈することができます。 特にウェブページのテストに役立ちます。
|
||||
|
||||
以降のチャレンジでは、Zombie.js を使用します。これは、追加のバイナリをインストールしなくても動作する軽量のヘッドレスブラウザーです。 この機能により、Replit のような限られた環境で使用できます。 ただし、他にも多くの高機能なヘッドレスブラウザーがあります。
|
||||
|
||||
Mocha では、実際のテストが実行される前にコードを実行できます。 これは、以降のテストで使用するデータベースへのエントリの追加などの操作を行うのに便利です。
|
||||
|
||||
ヘッドレスブラウザーでテストを行う前に、テストを行うページに**アクセス**してください。
|
||||
|
||||
`suiteSetup` フックは、テストスイートの始めに一度だけ実行されます。
|
||||
|
||||
他にも、各テストの前、各テストの後、またはテストスイートの終わりにコードを実行できるいくつかのフックタイプがあります。 詳細については、Mocha のドキュメントを参照してください。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/2_functional-tests.js` の中の `Browser` 宣言の直後で、変数の `site` プロパティにプロジェクトの URL を追加してください。
|
||||
|
||||
```js
|
||||
Browser.site = 'https://boilerplate-mochachai.your-username.repl.co'; // Your URL here
|
||||
```
|
||||
|
||||
次に、`'Functional Tests with Zombie.js'` スイートのルートレベルで、次のコードを使用して `Browser` オブジェクトの新しいインスタンスを生成してください。
|
||||
|
||||
```js
|
||||
const browser = new Browser();
|
||||
```
|
||||
|
||||
そして、次のコードを使用して、`suiteSetup`フックで `browser` を `/` ルートに移動させてください。
|
||||
|
||||
```js
|
||||
suiteSetup(function(done) {
|
||||
return browser.visit('/', done);
|
||||
});
|
||||
```
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=functional&n=4').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,101 @@
|
||||
---
|
||||
id: 587d824b367417b2b2512c49
|
||||
title: 真かどうかをテストする
|
||||
challengeType: 2
|
||||
forumTopicId: 301596
|
||||
dashedName: test-for-truthiness
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
`isTrue()` は、ブール値 `true` かどうかをテストし、`isNotTrue()` は、ブール値 `true` 以外の値である場合にテストにパスします。
|
||||
|
||||
```js
|
||||
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()` もあり、ブール値 `false` かどうかを調べること以外は対応する true 版のメソッドと同様に動作します。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/1_unit-tests.js` の中の、`Basic Assertions` スイート内の `#4` に分類されたテストにおいて、テストを合格にする (`true` と評価する必要があります) ために、それぞれの `assert` を `assert.isTrue` または `assert.isNotTrue` に変更してください。 アサートに渡された引数を変更しないでください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=3').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
最初のアサーションに対して、正しいメソッドを選ぶ必要があります - `isTrue` もしくは `isNotTrue` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=3').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[0].method, 'isTrue', 'True is true');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
2 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `isTrue` もしくは `isNotTrue` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=3').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[1].method,
|
||||
'isTrue',
|
||||
'Double negation of a truthy value is true'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
3 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `isTrue` もしくは `isNotTrue` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=3').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[2].method,
|
||||
'isNotTrue',
|
||||
'A truthy object is not true - neither is a false one'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,79 @@
|
||||
---
|
||||
id: 587d824d367417b2b2512c53
|
||||
title: 文字列に部分文字列が含まれているかどうかをテストする
|
||||
challengeType: 2
|
||||
forumTopicId: 301597
|
||||
dashedName: test-if-a-string-contains-a-substring
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
`include()` と `notInclude()` は、文字列でも動作します! `include()` は、実際の文字列が期待される部分文字列を含んでいることをアサートします。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/1_unit-tests.js` の中の、`Strings` スイート内の `#14` に分類されたテストにおいて、テストを合格にする (`true` と評価する必要があります) ために、それぞれの `assert` を `assert.include` または `assert.notInclude` に変更してください。 アサートに渡された引数を変更しないでください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=13').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
最初のアサーションに対して、正しいメソッドを選ぶ必要があります - `include` もしくは `notInclude` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=13').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[0].method,
|
||||
'include',
|
||||
"'Arrow' contains 'row'..."
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
2 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `include` もしくは `notInclude` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=13').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[1].method,
|
||||
'notInclude',
|
||||
"... a 'dart' doesn't contain a 'queue'"
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,87 @@
|
||||
---
|
||||
id: 587d824c367417b2b2512c4f
|
||||
title: 値が特定の範囲内かどうかをテストする
|
||||
challengeType: 2
|
||||
forumTopicId: 301598
|
||||
dashedName: test-if-a-value-falls-within-a-specific-range
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
```javascript
|
||||
.approximately(actual, expected, delta, [message])
|
||||
```
|
||||
|
||||
`actual` が `expected`に等しく +/- `delta` の範囲内であることをアサートします。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/1_unit-tests.js` の中の、`Comparisons` スイート内の `#10` に分類されたテストにおいて、テストを合格にする (`true` と評価する必要があります) ために、それぞれの `assert` を `assert.approximately` に変更してください。
|
||||
|
||||
テストを常に合格にするには、最小範囲 (3 番目のパラメータ) を選択してください。 範囲は、1 未満でなければなりません。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=9').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
最初のアサーションに対して、正しい範囲を選ぶ必要があります - `approximately(actual, expected, range)` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=9').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[0].method, 'approximately');
|
||||
assert.equal(
|
||||
data.assertions[0].args[2],
|
||||
0.5,
|
||||
"weirdNumbers(0.5) is in the range (0.5, 1.5]. It's within 1 +/- 0.5"
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
2 番目のアサーションに対して、正しい範囲を選ぶ必要があります - `approximately(actual, expected, range)` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=9').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[1].method, 'approximately');
|
||||
assert.equal(
|
||||
data.assertions[1].args[2],
|
||||
0.8,
|
||||
"weirdNumbers(0.2) is in the range (0.2, 1.2]. It's within 1 +/- 0.8"
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,93 @@
|
||||
---
|
||||
id: 587d824d367417b2b2512c52
|
||||
title: 値が文字列かどうかをテストする
|
||||
challengeType: 2
|
||||
forumTopicId: 301599
|
||||
dashedName: test-if-a-value-is-a-string
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
`isString` または `isNotString` は、実際の値が文字列であることをアサートします。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/1_unit-tests.js` の中の、`Strings` スイート内の `#13` に分類されたテストにおいて、テストを合格にする (`true` と評価する必要があります) ために、それぞれの `assert` を `assert.isString` または `assert.isNotString` に変更してください。 アサートに渡された引数を変更しないでください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=12').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
最初のアサーションに対して、正しいメソッドを選ぶ必要があります - `isString` もしくは `isNotString` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=12').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[0].method,
|
||||
'isNotString',
|
||||
'A float number is not a string'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
2 番目のアサーションに対して、正しいメソッドを選ぶ必要があります- `isString` もしくは `isNotString` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=12').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[1].method,
|
||||
'isString',
|
||||
'environment vars are strings (or undefined)'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
3 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `isString` もしくは `isNotString` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=12').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[2].method, 'isString', 'A JSON is a string');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: 587d824d367417b2b2512c50
|
||||
title: 値が配列かどうかをテストする
|
||||
challengeType: 2
|
||||
forumTopicId: 301600
|
||||
dashedName: test-if-a-value-is-an-array
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/1_unit-tests.js` の中の、`Arrays` スイート内の `#11` に分類されたテストにおいて、テストを合格にする (`true` と評価する必要があります) ために、それぞれの `assert` を `assert.isArray` または `assert.isNotArray` に変更してください。 アサート に渡された引数を変更しないでください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=10').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
最初のアサーションに対して、正しいメソッドを選ぶ必要があります - `isArray` もしくは `isNotArray`です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=10').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[0].method,
|
||||
'isArray',
|
||||
'String.prototype.split() returns an Array'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
2 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `isArray` もしくは `isNotArray` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=10').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[1].method,
|
||||
'isNotArray',
|
||||
'Array.prototype.indexOf() returns a number'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,133 @@
|
||||
---
|
||||
id: 587d824e367417b2b2512c56
|
||||
title: 値が特定のデータ構造タイプかどうかをテストする
|
||||
challengeType: 2
|
||||
forumTopicId: 301601
|
||||
dashedName: test-if-a-value-is-of-a-specific-data-structure-type
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
`#typeOf` は、値のタイプが、`Object.prototype.toString` で決まるとおりの与えられた文字列であることをアサートします。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/1_unit-tests.js` の中の、`Objects` スイート内の `#17` に分類されたテストにおいて、テストを合格にする (`true` と評価する必要があります) ために、それぞれの `assert` を `assert.typeOf` または `assert.notTypeOf` に変更してください。 アサートに渡された引数を変更しないでください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=16').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
最初のアサーションに対して、正しいメソッドを選ぶ必要があります - `typeOf` もしくは `notTypeOf` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=16').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[0].method,
|
||||
'typeOf',
|
||||
'myCar is typeOf Object'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
2 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `typeOf` もしくは `notTypeOf` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=16').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[1].method,
|
||||
'typeOf',
|
||||
'Car.model is a String'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
3 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `typeOf` もしくは `notTypeOf` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=16').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[2].method,
|
||||
'notTypeOf',
|
||||
'Plane.wings is a Number (not a String)'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
4 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `typeOf` もしくは `notTypeOf`です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=16').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[3].method,
|
||||
'typeOf',
|
||||
'Plane.engines is an Array'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
5 番目のアサーションに対して、正しいメソッドを選択する必要があります - `typeOf` もしくは `notTypeOf` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=16').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[4].method,
|
||||
'typeOf',
|
||||
'Car.wheels is a Number'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,95 @@
|
||||
---
|
||||
id: 587d824b367417b2b2512c47
|
||||
title: 変数または関数が定義されているかどうかをテストする
|
||||
challengeType: 2
|
||||
forumTopicId: 301602
|
||||
dashedName: test-if-a-variable-or-function-is-defined
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/1_unit-tests.js` の中の、`Basic Assertions` スイート内の `#2` に分類されたテストにおいて、テストに合格にする (`true` と評価する必要があります) ために、それぞれの `assert` を `assert.isDefined()` または `assert.isUndefined()` に変更してください。 アサートに渡された引数を変更しないでください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=1').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
最初のアサーションに対して、正しいメソッドを選ぶ必要があります - `isDefined` もしくは `isUndefined` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=1').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[0].method,
|
||||
'isDefined',
|
||||
'Null is not undefined'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
2 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `isDefined` もしくは `isUndefined` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=1').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[1].method,
|
||||
'isUndefined',
|
||||
'Undefined is undefined'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
3 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `isDefined` もしくは `isUndefined` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=1').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[2].method,
|
||||
'isDefined',
|
||||
'A string is not undefined'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: 587d824d367417b2b2512c51
|
||||
title: 配列にアイテムが含まれているかどうかをテストする
|
||||
challengeType: 2
|
||||
forumTopicId: 301603
|
||||
dashedName: test-if-an-array-contains-an-item
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/1_unit-tests.js` の中の、`Arrays` スイート内の `#12` に分類されたテストにおいて、テストを合格にする (`true` と評価する必要があります) ために、それぞれの `assert` を `assert.include` または `assert.notInclude` に変更してください。 アサートに渡された引数を変更しないでください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=11').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
最初のアサーションに対して、正しいメソッドを選ぶ必要があります - `include` もしくは `notInclude` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=11').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[0].method,
|
||||
'notInclude',
|
||||
"It's summer in july..."
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
2 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `include` もしくは `notInclude` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=11').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[1].method,
|
||||
'include',
|
||||
'JavaScript is a backend language !!'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,93 @@
|
||||
---
|
||||
id: 587d824e367417b2b2512c55
|
||||
title: オブジェクトにプロパティがあるかどうかをテストする
|
||||
challengeType: 2
|
||||
forumTopicId: 301604
|
||||
dashedName: test-if-an-object-has-a-property
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
`property` は、実際のオブジェクトに、与えられたプロパティがあることをアサートします。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/1_unit-tests.js` の中の、`Objects` スイート内の `#16` に分類されたテストにおいて、テストを合格にする (`true` と評価する必要があります) ために、それぞれの `assert` を `assert.property` または `assert.notProperty` に変更してください。 アサートに渡された引数を変更しないでください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=15').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
最初のアサーションに対して、正しいメソッドを選ぶ必要があります - `property` もしくは `notProperty` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=15').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[0].method,
|
||||
'notProperty',
|
||||
'A car has not wings'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
2 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `property` もしくは `notProperty` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=15').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[1].method,
|
||||
'property',
|
||||
'planes have engines'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
3 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `property` もしくは `notProperty` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=15').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[2].method, 'property', 'Cars have wheels');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,115 @@
|
||||
---
|
||||
id: 587d824e367417b2b2512c57
|
||||
title: オブジェクトがコンストラクターのインスタンスであるかどうかをテストする
|
||||
challengeType: 2
|
||||
forumTopicId: 301605
|
||||
dashedName: test-if-an-object-is-an-instance-of-a-constructor
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
`#instanceOf` は、オブジェクトがコンストラクターのインスタンスであることをアサートします。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/1_unit-tests.js` の中の、`Objects` スイート内の `#18` に分類されたテストにおいて、テストを合格にする (`true` と評価する必要があります) ために、それぞれの `assert` を `assert.instanceOf` または `assert.notInstanceOf` に変更してください。 アサートに渡された引数を変更しないでください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=17').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
最初のアサーションに対して、正しいメソッドを選ぶ必要があります - `instanceOf` もしくは `notInstanceOf` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=17').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[0].method,
|
||||
'notInstanceOf',
|
||||
'myCar is not an instance of Plane'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
2 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `instanceOf` もしくは `notInstanceOf` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=17').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[1].method,
|
||||
'instanceOf',
|
||||
'airlinePlane is an instance of Plane'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
3 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `instanceOf` もしくは `notInstanceOf` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=17').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[2].method,
|
||||
'instanceOf',
|
||||
'everything is an Object in JavaScript...'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
4 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `instanceOf` もしくは `notInstanceOf`です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=17').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[3].method,
|
||||
'notInstanceOf',
|
||||
'myCar.wheels is not an instance of String'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,109 @@
|
||||
---
|
||||
id: 587d824c367417b2b2512c4e
|
||||
title: ある値が、他の値より小さいか、もしくは他の値以上かをテストする
|
||||
challengeType: 2
|
||||
forumTopicId: 301606
|
||||
dashedName: test-if-one-value-is-below-or-at-least-as-large-as-another
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/1_unit-tests.js` の中の、`Comparisons` スイート内の `#9` に分類されたテストにおいて、テストを合格にする (`true` と評価する必要があります) ために、それぞれの `assert` を `assert.isBelow` または `assert.isAtLeast` に変更してください。 アサートに渡された引数を変更しないでください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=8').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
最初のアサーションに対して、正しいメソッドを選ぶ必要があります - `isBelow` もしくは `isAtLeast` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=8').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[0].method,
|
||||
'isAtLeast',
|
||||
'5 is at least (>=) 5'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
2 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `isBelow` もしくは `isAtLeast` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=8').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[1].method,
|
||||
'isAtLeast',
|
||||
'2 * Math.random() is at least 0'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
3 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `isBelow` もしくは `isAtLeast` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=8').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[2].method, 'isBelow', '1 is smaller than 2');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
4 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `isBelow` もしくは `isAtLeast` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=8').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[3].method,
|
||||
'isBelow',
|
||||
'2/3 (0.6666) is smaller than 1'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,87 @@
|
||||
---
|
||||
id: 587d824b367417b2b2512c48
|
||||
title: Assert.isOK と Assert.isNotOK を使用する
|
||||
challengeType: 2
|
||||
forumTopicId: 301607
|
||||
dashedName: use-assert-isok-and-assert-isnotok
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
`isOk()` は真値かどうかをテストし、 `isNotOk()` は偽値かどうかをテストします。
|
||||
|
||||
真値と偽値についてさらに学習するには、[Falsy Bouncer](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/falsy-bouncer) チャレンジに挑戦してください。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/1_unit-tests.js` の中の、`Basic Assertions` スイート内の `#3` に分類されたテストにおいて、テストを合格にする (`true` と評価する必要があります) ために、それぞれの `assert` を `assert.isOk()` または `assert.isNotOk()` に変更してください。 アサートに渡された引数を変更しないでください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=2').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
最初のアサーションに対して、正しいメソッドを選ぶ必要があります - `isOk` もしくは `isNotOk` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=2').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[0].method, 'isNotOk', 'Null is falsy');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
2 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `isOk` もしくは `isNotOk` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=2').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[1].method, 'isOk', 'A string is truthy');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
3 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `isOk` もしくは `isNotOk` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=2').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[2].method, 'isOk', 'true is truthy');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,79 @@
|
||||
---
|
||||
id: 587d824d367417b2b2512c54
|
||||
title: 文字列をテストするために正規表現を使用する
|
||||
challengeType: 2
|
||||
forumTopicId: 301608
|
||||
dashedName: use-regular-expressions-to-test-a-string
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
`match()` は、実際の値が 2 番目の引数の正規表現に一致することをアサートします。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/1_unit-tests.js` の中の、`Strings` スイート内の `#15` に分類されたテストにおいて、テストを合格にする (`true` と評価する必要があります) ために、それぞれの `assert` を `assert.match` または `assert.notMatch` に変更してください。 アサートに渡された引数を変更しないでください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=14').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
最初のアサーションに対して、正しいメソッドを選ぶ必要があります - `match` もしくは `notMatch` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=14').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[0].method,
|
||||
'match',
|
||||
"'# name:John Doe, age:35' matches the regex"
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
2 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `match` もしくは `notMatch` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=14').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[1].method,
|
||||
'notMatch',
|
||||
"'# name:Paul Smith III, age:twenty-four' does not match the regex (the age must be numeric)"
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,111 @@
|
||||
---
|
||||
id: 587d824b367417b2b2512c4a
|
||||
title: ダブルイコールを使用して等価をアサートする
|
||||
challengeType: 2
|
||||
forumTopicId: 301609
|
||||
dashedName: use-the-double-equals-to-assert-equality
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
`equal()` は、`==` を使用してオブジェクトを比較します。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/1_unit-tests.js` の中の、`Equality` スイート内の `#5` に分類されたテストにおいて、テストを合格にする(`true` と評価する必要があります)ために、それぞれの `assert` を `assert.equal` または `assert.notEqual` に変更してください。 アサートに渡された引数を変更しないでください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=4').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
最初のアサーションに対して、正しいメソッドを選ぶ必要があります - `equal` もしくは `notEqual` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=4').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[0].method,
|
||||
'equal',
|
||||
'Numbers are coerced into strings with == '
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
2 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `equal` もしくは `notEqual` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=4').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[1].method,
|
||||
'notEqual',
|
||||
' == compares object references'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
3 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `equal` もしくは `notEqual` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=4').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[2].method,
|
||||
'equal',
|
||||
"6 * '2' is 12 ! It should be equal to '12'"
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
4 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `equal` もしくは `notEqual` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=4').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[3].method, 'notEqual', "6 + '2' is '62'...");
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
@@ -0,0 +1,111 @@
|
||||
---
|
||||
id: 587d824b367417b2b2512c4b
|
||||
title: トリプルイコールを使用して厳密等価をアサートする
|
||||
challengeType: 2
|
||||
forumTopicId: 301610
|
||||
dashedName: use-the-triple-equals-to-assert-strict-equality
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||||
|
||||
`strictEqual()` は、`===` を使用してオブジェクトを比較します。
|
||||
|
||||
# --instructions--
|
||||
|
||||
`tests/1_unit-tests.js` 内で、`Equality` スイートの `#6` に分類されるテストにおいて、(`true` と評価する必要がある) テストに合格にするために、各 `assert` を `assert.strictEqual` または `assert.notStrictEqual` のいずれかに変更してください。 アサートに渡された引数を変更しないでください。
|
||||
|
||||
# --hints--
|
||||
|
||||
すべてのテストに合格する必要があります。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=5').then(
|
||||
(data) => {
|
||||
assert.equal(data.state, 'passed');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
最初のアサーションに対して、正しいメソッドを選ぶ必要があります - `strictEqual` もしくは `notStrictEqual` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=5').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[0].method,
|
||||
'notStrictEqual',
|
||||
'with strictEqual the type must match'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
2 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `strictEqual` もしくは `notStrictEqual` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=5').then(
|
||||
(data) => {
|
||||
assert.equal(data.assertions[1].method, 'strictEqual', '3*2 = 6...');
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
3 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `strictEqual` もしくは `notStrictEqual` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=5').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[2].method,
|
||||
'strictEqual',
|
||||
"6 * '2' is 12. Types match !"
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
4 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `strictEqual` もしくは `notStrictEqual` です。
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=5').then(
|
||||
(data) => {
|
||||
assert.equal(
|
||||
data.assertions[3].method,
|
||||
'notStrictEqual',
|
||||
'Even if they have the same elements, the Arrays are notStrictEqual'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
throw new Error(xhr.responseText);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
/**
|
||||
Backend challenges don't need solutions,
|
||||
because they would need to be tested against a full working project.
|
||||
Please check our contributing guidelines to learn more.
|
||||
*/
|
||||
```
|
Reference in New Issue
Block a user