|
| 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 | +``` |
0 commit comments