move files from testing repo to this repo

This commit is contained in:
Michael Frank
2021-04-30 21:49:46 +12:00
parent fb304675d8
commit 35d7948aa2
17 changed files with 624 additions and 583 deletions
+2 -2
View File
@@ -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...