Skip to content

Commit c211ef9

Browse files
alexeaglemhevery
authored andcommitted
docs: add documentation for integration test setup (angular#14368)
1 parent a7688d2 commit c211ef9

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

integration/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Integration tests for Angular
2+
3+
This directory contains end-to-end tests for Angular. Each directory is a self-contained
4+
application that exactly mimics how a user might expect Angular to work, so they allow
5+
high-fidelity reproductions of real-world issues.
6+
7+
For this to work, we first build the Angular distribution just like we would publish
8+
it to npm, then install the distribution into each app.
9+
10+
## Writing an integration test
11+
12+
The API for each test is:
13+
14+
- Each sub-directory here is an integration test
15+
- Each test should have a `package.json` file
16+
- The test runner will run `yarn` and `yarn test` on the package
17+
18+
This means that the test should be started by test script, like
19+
```
20+
'scripts' { 'test': 'runProgramA && assertResultIsGood' }
21+
```
22+
23+
Note that the `package.json` file uses a special `file://../../dist` scheme
24+
to reference the Angular packages, so that the locally-built Angular
25+
is installed into the test app.
26+
27+
Also, beware of floating (non-shrinkwrapped) dependencies. If in doubt
28+
you can install the package directly from `file:../../node_modules`. For example,
29+
this is useful for protractor, which has a slow post-install step
30+
(`webdriver-manager update`) that can be skipped when the package from
31+
Angular's `node_modules` is installed.
32+
33+
## Running integration tests
34+
35+
The first time you run the tests, you'll need some setup:
36+
37+
```shell
38+
$ EXPERIMENTAL_ES2015_DISTRO=1 ./build.sh
39+
$ ./integration/build_rxjs_es6.sh
40+
```
41+
42+
Now you can iterate on the tests by keeping the dist folder up-to-date.
43+
See the `package.json` of the test(s) you're debugging, to see which dist/ folders they install from.
44+
Then run the right `tsc --watch` command to keep those dist folders up-to-date, for example:
45+
46+
```
47+
$ ./node_modules/.bin/tsc -p modules/@angular/core/tsconfig-build.json --target es2015 --outDir dist/packages-dist-es2015/core --watch
48+
```
49+
50+
Now you can run the integration test, it will re-install from the dist/ folder on each run.
51+
52+
```
53+
$ ./integration/run_tests.sh
54+
```

integration/run_tests.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ set -e -o pipefail
55
cd `dirname $0`
66

77
if [ ! -d "rxjs/dist/es6" ]; then
8-
echo "You must run build_rxjs_es6.sh before running tests"
8+
echo "You must run build the ES2015 version of RxJS for some tests:"
9+
echo "./integration/build_rxjs_es6.sh"
10+
exit 1
11+
fi
12+
13+
if [ ! -d "../dist/packages-dist-es2015" ]; then
14+
echo "You must build the ES2015 distro for some tests:"
15+
echo "EXPERIMENTAL_ES2015_DISTRO=1 ./build.sh"
916
exit 1
1017
fi
1118

0 commit comments

Comments
 (0)