mirror of
https://github.com/10h30/odin-javascript-exercises.git
synced 2026-06-05 15:09:09 +09:00
Added jest
Removed generator-exercises folder as it breaks jest-codemods run jest-codemods on .spec.js files, move generator-exercises back in Change references from Jasmine to Jest in main readme Update README with Jest specific language. Update some spec files with new syntax update tests, multiple exercises .gitignore: Added package-lock.json, package.json that were used when I ran code-blocks over the tests. Standardised function declaration calls across exercises fix typo in caesar.spec.js Ignoring package-lock.json, package.json Backtrack on .gitignore modification, add instructions to readme move files from testing repo to this repo Typo fixes, remove duplicate exercise folder Remove solution from non-solution branch Minor grammatical fixes added trailing semicolon to all function and module exports Fix words caught by search/replace action. remove doubled semicolon. Correct words caught by search/replace action. Add missing semicolon. Add .DS_Store to .gitignore multiple files: Added a blank line at the end of each file Ignore generator-exercise when linting exercise files Update exercise number of each exercise Update exercise number
This commit is contained in:
committed by
Kevin Mulhern
parent
4c771f2e05
commit
5708c3d85a
@@ -1,4 +1,4 @@
|
||||
# Exercise 01 - Hello World.
|
||||
# Exercise 01 - Hello World
|
||||
|
||||
The main purpose of this exercise is to walk you through the process of running the tests and make sure everything is set up and running correctly.
|
||||
|
||||
@@ -13,16 +13,16 @@ 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...
|
||||
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 `npm test 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...
|
||||
|
||||
so let's look at the javascript file:
|
||||
```javascript
|
||||
|
||||
@@ -2,4 +2,4 @@ const helloWorld = function() {
|
||||
return ''
|
||||
}
|
||||
|
||||
module.exports = helloWorld
|
||||
module.exports = helloWorld;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
const helloWorld = require('./helloWorld');
|
||||
|
||||
describe('Hello World', function() {
|
||||
it('says hello world', function() {
|
||||
expect(helloWorld()).toEqual('Hello, World!');
|
||||
});
|
||||
test('says "Hello, World!"', function() {
|
||||
expect(helloWorld()).toBe("Hello, World!");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user