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

Skip to content

Commit 59dd4b0

Browse files
jasssonpetwardbell
authored andcommitted
docs(testing): fix typos, exclude node_modules from tsconfig (angular#763)
closes angular#723
1 parent 6e11cf6 commit 59dd4b0

File tree

2 files changed

+38
-35
lines changed

2 files changed

+38
-35
lines changed

public/docs/ts/latest/testing/first-app-tests.jade

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include ../../../../_includes/_util-fns
22

33
:marked
4-
In this chapter well setup the environment for testing our sample application and write a few easy Jasmine tests of the apps simplest parts.
4+
In this chapter we'll setup the environment for testing our sample application and write a few easy Jasmine tests of the app's simplest parts.
55
We'll learn:
66
- to test one of our application classes
77
- why we prefer our test files to be next to their corresponding source files
@@ -44,14 +44,14 @@ include ../../../../_includes/_util-fns
4444
</html>
4545
```
4646

47-
Were picking up right where we left off. All weve done is change the title.
47+
We're picking up right where we left off. All we've done is change the title.
4848

4949
.l-main-section
5050
:marked
5151
## Update `package.json` for testing
5252

53-
Well assume that the application has `package.json` file that looks more or less like
54-
the one we prescribed in the in the Install npm packages locally section of the
53+
We'll assume that the application has `package.json` file that looks more or less like
54+
the one we prescribed in the in the "Install npm packages locally" section of the
5555
[QuickStart](../quickstart.html).
5656

5757
We must install the Jasmine package as well:
@@ -62,7 +62,7 @@ pre.prettyprint.lang-bash
6262
.alert.is-important Be sure to install <code>jasmine-core</code> , not <code>jasmine</code>!
6363

6464
:marked
65-
Lets make one more change to the `package.json` script commands.
65+
Let's make one more change to the `package.json` script commands.
6666

6767
**Open the `package.json` ** and scroll to the `scripts` node. Look for the command named `test`. Change it to:
6868

@@ -96,16 +96,16 @@ pre.prettyprint.lang-bash
9696
}
9797
```
9898

99-
Lets add a couple of simple tests in the `<body>` element.
99+
Let's add a couple of simple tests in the `<body>` element.
100100

101-
First, well load the JavaScript file that defines the `Hero` class.
101+
First, we'll load the JavaScript file that defines the `Hero` class.
102102

103103
```
104104
<!-- load the application's Hero definition -->
105105
<script src="app/hero.js"></script>
106106
```
107107

108-
Next, well add an inline script element with the `Hero`tests themselves
108+
Next, we'll add an inline script element with the `Hero`tests themselves
109109

110110
```
111111
<script>
@@ -126,7 +126,7 @@ pre.prettyprint.lang-bash
126126
</script>
127127
```
128128

129-
Thats the basic Jasmine we learned back in Jasmine 101.
129+
That's the basic Jasmine we learned back in "Jasmine 101".
130130

131131
Notice that we surrounded our tests with ** `describe('Hero')` **.
132132

@@ -152,13 +152,13 @@ figure.image-display
152152
:marked
153153
## Critique
154154

155-
Is this `Hero` class even worth testing? Its essentially a property bag with almost no logic. Maybe we should have tested the cloning feature. Maybe we should have tested id generation. We didnt bother because there wasnt much to learn by doing that.
155+
Is this `Hero` class even worth testing? It's essentially a property bag with almost no logic. Maybe we should have tested the cloning feature. Maybe we should have tested id generation. We didn't bother because there wasn't much to learn by doing that.
156156

157-
Its more important to take note of the `//Demo only` comment in the `unit-tests.html`.
157+
It's more important to take note of the `//Demo only` comment in the `unit-tests.html`.
158158

159-
** Well never write real tests in the HTML this way**. Its nice that we can write *some* of our application tests directly in the HTML. But dumping all of our tests into HTML is not sustainable and even if we didnt mind that approach, we could only test a tiny fraction of our app this way.
159+
** We'll never write real tests in the HTML this way**. It's nice that we can write *some* of our application tests directly in the HTML. But dumping all of our tests into HTML is not sustainable and even if we didn't mind that approach, we could only test a tiny fraction of our app this way.
160160

161-
We need to relocate these tests to a separate file. Lets do that next.
161+
We need to relocate these tests to a separate file. Let's do that next.
162162

163163
.l-main-section
164164
:marked
@@ -173,17 +173,17 @@ figure.image-display
173173
- When we move the source (inevitable), we remember to move the test.
174174
- When we rename the source file (inevitable), we remember to rename the test file.
175175

176-
We cant think of a downside. The server doesnt care where they are. They are easy to find and distinguish from application files when named conventionally.
176+
We can't think of a downside. The server doesn't care where they are. They are easy to find and distinguish from application files when named conventionally.
177177

178-
You may put your tests elsewhere if you wish. Were putting ours inside the app, next to the source files that they test.
178+
You may put your tests elsewhere if you wish. We're putting ours inside the app, next to the source files that they test.
179179

180180
.l-main-section
181181
:marked
182182
## First spec file
183183

184184
**Create** a new file, ** `hero.spec.ts` ** in `src/app` next to `hero.ts`.
185185

186-
Notice the .spec suffix in the test files filename, appended to the name of the file holding the application part were testing.
186+
Notice the ".spec" suffix in the test file's filename, appended to the name of the file holding the application part we're testing.
187187

188188
.alert.is-important All of our unit test files follow this .spec naming pattern.
189189

@@ -208,13 +208,13 @@ figure.image-display
208208

209209
```
210210

211-
### Import the part were testing
211+
### Import the part we're testing
212212

213213
During our conversion to TypeScript, we added an `import {Hero} from './hero' ` statement.
214214

215-
If we forgot this import, a TypeScript-aware editor would warn us, with a squiggly red underline, that it cant find the definition of the `Hero` class.
215+
If we forgot this import, a TypeScript-aware editor would warn us, with a squiggly red underline, that it can't find the definition of the `Hero` class.
216216

217-
TypeScript doesnt know what a `Hero` is. It doesnt know about the script tag back in the `unit-tests.html` that loads the `hero.js` file.
217+
TypeScript doesn't know what a `Hero` is. It doesn't know about the script tag back in the `unit-tests.html` that loads the `hero.js` file.
218218

219219
### Update unit-tests.html
220220

@@ -231,9 +231,9 @@ figure.image-display
231231
img(src='/resources/images/devguide/first-app-tests/Jasmine-not-running-tests.png' style="width:400px;" alt="Jasmine not running any tests")
232232

233233
:marked
234-
Thats Jasmine saying **things are _so_ bad that _Im not running any tests_.**
234+
That's Jasmine saying "**things are _so_ bad that _I'm not running any tests_.**"
235235

236-
Open the browsers Developer Tools (F12, Ctrl-Shift-i). Theres an error:
236+
Open the browser's Developer Tools (F12, Ctrl-Shift-i). There's an error:
237237

238238
code-example(format="" language="html").
239239
Uncaught ReferenceError: exports is not defined
@@ -244,10 +244,10 @@ code-example(format="" language="html").
244244

245245
The immediate cause of the error is the `export` statement in `hero.ts`.
246246
That error was there all along.
247-
It wasnt a problem until we tried to `import` the `Hero` class in our tests.
247+
It wasn't a problem until we tried to `import` the `Hero` class in our tests.
248248

249249
Our test environment lacks support for module loading.
250-
Apparently we cant simply load our application and test scripts like we do with 3rd party JavaScript libraries.
250+
Apparently we can't simply load our application and test scripts like we do with 3rd party JavaScript libraries.
251251

252252
We are committed to module loading in our application.
253253
Our app will call `import`. Our tests must do so too.
@@ -301,36 +301,36 @@ figure.image-display
301301

302302
### System.config
303303
System.js demands that we specify a default extension for the filenames that correspond to whatever it is asked to import.
304-
Without that default, it would translate an import statement such as `import {Hero} from ‘./here’` to a request for the file named `hero`.
305-
Not `hero.js`. Just plain `hero`. Our server error with 404 - not found because it doesnt have a file of that name.
304+
Without that default, it would translate an import statement such as `import {Hero} from './hero'` to a request for the file named `hero`.
305+
Not `hero.js`. Just plain `hero`. Our server error with "404 - not found" because it doesn't have a file of that name.
306306

307-
Once configured with a default extension of ‘js’,&nbsp; Systemjs requests `hero.js` which *does* exist and is promptly returned by our server.
307+
Once configured with a default extension of 'js',&nbsp; Systemjs requests `hero.js` which *does* exist and is promptly returned by our server.
308308

309309
### Asynchronous System.import
310-
The call to `System.import` shouldnt surprise us but its asynchronous nature might.
310+
The call to `System.import` shouldn't surprise us but it's asynchronous nature might.
311311
If we ponder this for a moment, we realize that it must be asynchronous because
312312
System.js may have to fetch the corresponding JavaScript file from the server.
313313
Accordingly, `System.import` returns a promise and we must wait for that promise to resolve.
314314
Only then can Jasmine start evaluating the imported tests.
315315

316316
### window.onload
317-
Jasmine doesnt have a `start` method. It wires its own start to the browser windows `load` event.
318-
That makes sense if were loading our tests with script tags.
317+
Jasmine doesn't have a `start` method. It wires its own start to the browser window's `load` event.
318+
That makes sense if we're loading our tests with script tags.
319319
The browser raises the `load` event when it finishes loading all scripts.
320320

321-
But were not loading test scripts inline anymore.
322-
Were using the systemjs module loader and it wont be done until long after the browser raised the `load` event.
321+
But we're not loading test scripts inline anymore.
322+
We're using the systemjs module loader and it won't be done until long after the browser raised the `load` event.
323323
Meanwhile, Jasmine started and ran to completion … with no tests to evaluate … before the import completed.
324324

325325
So we must wait until the import completes and only then call the window `onLoad` handler.
326326
Jasmine re-starts, this time with our imported test queued up.
327327

328328
.l-main-section
329329
:marked
330-
## Whats Next?
330+
## What's Next?
331331
We are able to test a part of our application with simple Jasmine tests.
332332
The part was a stand-alone class that made no mention or use of Angular.
333333

334-
Thats not rare but its not typical either. Most of our application parts make some use of the Angular framework.
334+
That's not rare but it's not typical either. Most of our application parts make some use of the Angular framework.
335335

336-
In the [next chapter](testing-an-angular-pipe.html), well test a class that does rely on Angular.
336+
In the [next chapter](testing-an-angular-pipe.html), we'll test a class that does rely on Angular.

public/docs/ts/latest/testing/jasmine-testing-101.jade

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ figure.image-display
114114
"sourceMap": true,
115115
"emitDecoratorMetadata": true,
116116
"experimentalDecorators": true
117-
}
117+
},
118+
"exclude": [
119+
"node_modules"
120+
]
118121
}
119122
```
120123
## Compile and Run

0 commit comments

Comments
 (0)