mirror of
https://github.com/10h30/odin-javascript-exercises.git
synced 2026-06-05 15:09:09 +09:00
move files from testing repo to this repo
This commit is contained in:
@@ -13,14 +13,14 @@ Let's look at the spec file first:
|
||||
const helloWorld = require('./helloWorld');
|
||||
|
||||
describe('Hello World', function() {
|
||||
it('says hello world', function() {
|
||||
test('says hello world', function() {
|
||||
expect(helloWorld()).toEqual('Hello, World!');
|
||||
});
|
||||
});
|
||||
```
|
||||
At the very top of the file we use `require()` to import the code from the javascript file (`helloWorld.js`) so that we can test it.
|
||||
|
||||
The next block (`describe()`) is the body of the test. Basically, all it's doing is running your code and testing to see if the output is correct. The `it()` function describes what should be happening in plain english and then includes the `expect()` function. For this simple example it should be pretty simple to read.
|
||||
The next block (`describe()`) is the body of the test. Basically, all it's doing is running your code and testing to see if the output is correct. The `test()` function describes what should be happening in plain english and then includes the `expect()` function. For this simple example it should be pretty simple to read.
|
||||
|
||||
For now you do not need to worry about how to write tests, but you should try to get comfortable enough with the syntax to figure out what the tests are asking you to do. Go ahead and run the tests by entering `jasmine helloWorld.spec.js` in the terminal and watch it fail. The output from that command should tell you exactly what went wrong with your code. In this case, running the `helloWorld()` function should return the phrase 'Hello, World!' but instead it returns an empty string...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user