Skip to content

Commit 35d7948

Browse files
author
Michael Frank
committed
move files from testing repo to this repo
1 parent fb30467 commit 35d7948

File tree

17 files changed

+624
-583
lines changed

17 files changed

+624
-583
lines changed

README.md

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,15 @@ There will eventually be a suggested order of completion, but at this time since
66
2. Repeat String
77
3. Reverse String
88

9-
## Setting Up
9+
## How To Use These Exercises
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).
12-
2. 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. Jest. Jest is a testing framework for JavaScript. To install it, navigate to your local copy of the repository and type `npm install --save-dev jest`. We use `--save-dev` here to specify this module is for development purposes only.
14-
15-
Once Jest has been installed, you should see a few additional files and folders appear in your repository:
16-
17-
* :file_folder: node_modules
18-
* :page_facing_up: package-lock.json
19-
* :page_facing_up: package.json
20-
21-
Open the `package.json` file in your text editor, and add the following code:
12+
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).
2214

23-
```json
24-
"scripts": {
25-
"test": "jest"
26-
}
27-
```
28-
29-
So that the end result looks something like this (don't worry if your jest version is different):
30-
31-
```json
32-
{
33-
"devDependencies": {
34-
"jest": "^26.6.3"
35-
}, <-- take note of the comma here
36-
"scripts": {
37-
"test": "jest"
38-
}
39-
}
40-
```
41-
That's it! Jest should be fully functional now. Onto the next section where we learn how to use it.
42-
43-
## How To Use These Exercises
4415
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.
4516

46-
**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.
17+
**Note**: Due to the way Jest handles failed tests, it will return an etest.skip 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.
4718

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

caesar/caesar.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const caesar = require('./caesar.js')
1+
const caesar = require('./caesar')
22

33
test('works with single letters', () => {
44
expect(caesar('A', 1)).toBe('B');

generator-exercise/generators/app/templates/title.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
let <%= title %> = require('./<%=title%>')
22

33
describe('<%=title%>', function() {
4-
it('EDITME', function() {
4+
test('EDITME', function() {
55
expect(<%=title%>()).toEqual(' ');
66
});
77

generator-exercise/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

helloWorld/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ Let's look at the spec file first:
1313
const helloWorld = require('./helloWorld');
1414

1515
describe('Hello World', function() {
16-
it('says hello world', function() {
16+
test('says hello world', function() {
1717
expect(helloWorld()).toEqual('Hello, World!');
1818
});
1919
});
2020
```
2121
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.
2222

23-
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.
23+
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.
2424

2525
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...
2626

0 commit comments

Comments
 (0)