Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e73c68f

Browse files
author
Michael Frank
committed
Update README with Jest specific language. Update some spec files with new syntax
1 parent 91d5028 commit e73c68f

File tree

5 files changed

+28
-22
lines changed

5 files changed

+28
-22
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ There will eventually be a suggested order of completion, but at this time since
1010
Before you start you should have a few things installed on your machine:
1111
1. NPM. To check if you have NPM installed, type `npm --version` in your terminal. If you get back `Command 'npm' not found, but can be installed with:`, do NOT follow the instructions in the terminal to install with `apt-get`. (This causes permission issues.) Instead, install Node with NVM by following the instructions [here](https://github.com/TheOdinProject/curriculum/blob/master/foundations/installations/installing_node.md).
1212
2. Jest. Jest is a testing framework for JavaScript. To install it, type `npm install --save-dev jest`. We use `--save-dev` here to specify this module is for development purposes only.
13-
3. A copy of this repository. Copies of repositories on your machine are called clones. If you need help cloning, you can learn how [here](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository)
13+
3. A copy of this repository. Copies of repositories on your machine are called clones. If you need help cloning, you can learn how [here](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository).
1414

15-
Each exercise includes 3 files: a markdown file with a description of the task, an empty (or mostly empty) JavaScript file, and a set of tests. To complete an exercise, you'll need to go to the exercise directory with `cd exerciseName` in the terminal and run `npm test exerciseName.spec.js`. This should run the test file and show you the output. When you first run a test, it will fail. This is by design! You must open the exercise file and write the code needed to get the test to pass. Some of the exercises have test conditions defined in their spec file that are defined as 'xit' compared to 'it'. This is purposeful. After you pass your first 'it', you will change the next 'xit' to an 'it' and test your code again. You'll do this until all conditions are satisfied.
15+
Each exercise includes 3 files: a markdown file with a description of the task, an empty (or mostly empty) JavaScript file, and a set of tests. To complete an exercise, you'll need to go to the exercise directory with `cd exerciseName` in the terminal and run `npm test exerciseName.spec.js`. This should run the test file and show you the output. When you first run a test, it will fail. This is by design! You must open the exercise file and write the code needed to get the test to pass. Some of the exercises have test conditions defined in their spec file that are defined as 'test.skip' compared to 'test'. This is purposeful. After you pass your first 'test', you will change the next 'test.skip' to an 'test' and test your code again. You'll do this until all conditions are satisfied.
16+
17+
**Note**: Due to the way Jest handles failed tests, it will return an exit code of 1 if any tests fail. NPM will interpret this as an error and you may see some `npm ERR!` messages after Jest runs. You can ignore these, or run your test with `npm test exerciseName.spec.js --silent` to supress the errors.
1618

1719
The first exercise, `helloWorld`, will walk you through the process in-depth.
1820

caesar/caesar.spec.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1-
const expect = require('expect');const caesar = require('./caesar')
1+
const expect = require('expect');
2+
const caesar = require('./caesar')
23

34
describe('caesar', function() {
4-
it('works with single letters', function() {
5-
expect(caesar('A', 1)).toEqual('B');
5+
test('works with single letters', function() {
6+
expect(caesar('A', 1)).toBe('B');
67
});
7-
xit('works with words', function() {
8-
expect(caesar('Aaa', 1)).toEqual('Bbb');
8+
test.skip('works with words', function() {
9+
expect(caesar('Aaa', 1)).toBe('Bbb');
910
});
10-
xit('works with phrases', function() {
11-
expect(caesar('Hello, World!', 5)).toEqual('Mjqqt, Btwqi!');
11+
test.skip('works with phrases', function() {
12+
expect(caesar('Hello, World!', 5)).toBe('Mjqqt, Btwqi!');
1213
});
13-
xit('works with negative shift', function() {
14-
expect(caesar('Mjqqt, Btwqi!', -5)).toEqual('Hello, World!');
14+
test.skip('works with negative shift', function() {
15+
expect(caesar('Mjqqt, Btwqi!', -5)).toBe('Hello, World!');
1516
});
16-
xit('wraps', function() {
17-
expect(caesar('Z', 1)).toEqual('A');
17+
test.skip('wraps', function() {
18+
expect(caesar('Z', 1)).toBe('A');
1819
});
19-
xit('works with large shift factors', function() {
20-
expect(caesar('Hello, World!', 75)).toEqual('Ebiil, Tloia!');
20+
test.skip('works with large shift factors', function() {
21+
expect(caesar('Hello, World!', 75)).toBe('Ebiil, Tloia!');
2122
});
22-
xit('works with large negative shift factors', function() {
23-
expect(caesar('Hello, World!', -29)).toEqual('Ebiil, Tloia!');
23+
test.skip('works with large negative shift factors', function() {
24+
expect(caesar('Hello, World!', -29)).toBe('Ebiil, Tloia!');
2425
});
2526
});

helloWorld/helloWorld.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const helloWorld = function() {
2-
return ''
2+
return 'Yello Wold!'
33
}
44

55
module.exports = helloWorld;

helloWorld/helloWorld.spec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const expect = require('expect');const { expect } = require('@jest/globals');
1+
const expect = require('expect');
22
const helloWorld = require('./helloWorld');
33

44
// describe('Hello World', function() {
@@ -7,6 +7,8 @@ const helloWorld = require('./helloWorld');
77
// });
88
// });
99

10-
test('says "Hello, World!"', () => {
11-
expect(helloWorld()).toBe("Hello, World!");
10+
describe('helloWorld', function() {
11+
test('says "Hello, World!"', function() {
12+
expect(helloWorld()).toBe("Hello, World!");
13+
})
1214
});

leapYears/leapYears.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const expect = require('expect');const leapYears = require('./leapYears')
1+
const expect = require('expect');
2+
const leapYears = require('./leapYears')
23

34
describe('leapYears', function() {
45
it('works with non century years', function() {

0 commit comments

Comments
 (0)