You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+78-3Lines changed: 78 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -7,11 +7,86 @@ JavaScript Variables Lab
7
7
8
8
## Instructions
9
9
10
-
In this lab, you'll need to declare some variables using `const` and `let`.
10
+
Ok, so this is your first lab. You'll notice a few new things in this lesson that we haven't encountered before. Don't worry, we'll walk you through them.
11
11
12
-
As usual, start by running the specs and reading the results.
12
+
### Tests...
13
13
14
-
Remember the workflow:
14
+
The first new thing you'll notice is tests. When we want to run an experiment, we need to develop a hypothesis and we need to test it. In programming, we run tests serve as our experiment to verify that programs behave the way we think they do. Tests help us identify bugs, and they give us a sense of the health of our applications.
15
+
16
+
Here, we use tests as teaching tools. Just like in a normal coding environment, we use tests to describe the program's behavior. You are in charge of getting the tests to pass.
17
+
18
+
### Structure
19
+
20
+
The structure of this lab — where its files and folders are located — looks roughly like the following:
21
+
22
+
```
23
+
├── CONTRIBUTING.md
24
+
├── LICENSE.md
25
+
├── README.md
26
+
├── index.js
27
+
├── node_modules/
28
+
├── package.json
29
+
└── test
30
+
└── index-test.js
31
+
```
32
+
33
+
All labs will more or less have the same structure. (And READMEs, for that matter, will still have CONTRIBUTING.md, LICENSE.md, and README.md files.)
34
+
35
+
### Code-along
36
+
37
+
For now, open up `index.js` in your text editor. If you're using the Learn IDE, click the "Open" button in the top right hand corner of the lesson. If you open up that "js-basic-variables-lab" folder, you'll see a list of files (along with a test/ directory). Click `index.js`, and it will open in the editor.
38
+
39
+
In `index.js`, you should see, well, nothing. We'll fix that soon.
40
+
41
+
Now open up `test/index-test.js`. Hey, there's something! What's all of this stuff doing?
42
+
43
+
**Note: The `test/index-test.js` has great info that we want to look at, but do not edit this file otherwise you may have extra difficulty passing this lab.**
44
+
45
+
A few lines down in the `test/index-test.js` file you will see:
46
+
47
+
```js
48
+
describe('Using Variables', () => {
49
+
// there's stuff in here, too
50
+
})
51
+
```
52
+
53
+
`describe` is a function provided by our test library, Mocha. The word is basically used to hold our tests. You can see that after the word `describe` is a description about our tests. Tests are used as a way to document the behavior of a function to developers, and you can see that examples of that after the words `describe`. For example, the next word `describe` is followed by the word `companyName` name. Here the test is telling us that the tests that come after words will be about `companyName`. Then comes the word `it`, where you see the following:
54
+
55
+
```js
56
+
it('is set as Scuber', () => {
57
+
// tests are here
58
+
})
59
+
```
60
+
61
+
So this is telling us that the `companyName` should be set to `Scuber`. Finally, filling in the missing part of the `it` code, we see:
62
+
63
+
```js
64
+
it('is set as Scuber', () => {
65
+
expect(companyName).to.equal('Scuber')
66
+
})
67
+
```
68
+
69
+
Here, we can see that it expects `companyName` to equal `Scuber`. That `expect` and `to.equal` are essentially doing the same thing as `companyName == 'Scuber'`. In other words, `expect(companyName).to.equal('Scuber')` is running code that will have this first test pass if `companyName` equals `Scuber` and fail if it does not.
70
+
71
+
Don't worry too much yet if it's hard to understand what is happening inside of the `test/indexTest.js` file. But it's a good idea to open up the file, and gather the information that you can. We will also provide Instructions in the `Readme.md` file that will allow you to complete the lab (as we do in this lab below).
72
+
73
+
## Running the Tests
74
+
75
+
To run the tests, simply type `learn-test` in the terminal part of the Learn IDE. (The terminal is the part below where you've been coding.)
76
+
77
+
Running the `learn-test` command will open up a new tab on your browser, showing the current status of the tests. For the moment, all of the tests fail. Let's figure out how to get one of them passing! (The rest will be up to you.)
78
+
79
+
To get our first test to pass, we can open up our `index.js` file, and write the following:
80
+
81
+
```js
82
+
83
+
let companyName ='Scuber'
84
+
85
+
```
86
+
87
+
Great, our first test is now passing. Except the second test is also about `companyName` and it is not. It's not passing because, it expects a change to `companyName` to throw a `TypeError`. It sounds like it wants `companyName` to be declared using a different keyword than the `let` keyword - it needs a keyword that is used for variables that can't be changed...
88
+
89
+
Ok, so we'll let you work through the problems below. But in summary here is your workflow for a lab:
0 commit comments