Skip to content

Commit

Permalink
Remove rxjs from default imports (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
thymikee authored Apr 13, 2017
1 parent baee16a commit 5d0b97d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Problems may arise if you're using custom builds (this preset is tailored for `a

### Absolute imports

TypeScript supports absolute imports. The preset by default understands all absolute imports referring to `src` directory, so instead:
TypeScript supports absolute imports. The preset by default understands all absolute imports referring to `src` directory, so instead:
```js
import MyComponent from '../../src/app/my.component';
import MyStuff from '../../src/testing/my.stuff';
Expand Down Expand Up @@ -134,3 +134,20 @@ By default Jest doesn't transform `node_modules`, because they should be valid J
}
```
This tells `ts-jest` (a preprocessor this preset using to transform TS files) to treat JS files the same as TS ones.

### Observable ... is not a function

Since v1.0 this preset doesn't import whole `rxjs` library by default for variety of reasons. This may result in breaking your tests that relied on this behavior. It may however become cumbersome to include e.g. `rxjs/add/operator/map` or `rxjs/add/operator/do` for every test, so as a workaround you can include common operators or other necessary imports in your `setupJest.ts` file:

```js
import 'jest-preset-angular';

// common rxjs imports
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/catch';
// ...

import './jestGlobalMocks';
```
1 change: 0 additions & 1 deletion setupJest.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ require('zone.js/dist/proxy.js');
require('zone.js/dist/sync-test');
require('zone.js/dist/async-test');
require('zone.js/dist/fake-async-test');
require('rxjs');
require('jest-zone-patch');
const { getTestBed } = require('@angular/core/testing');
const {
Expand Down

0 comments on commit 5d0b97d

Please sign in to comment.