Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @types/jest, upgrade example app dependencies, README and CHANGELOG #116

Merged
merged 3 commits into from
Jan 27, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* Breaking: Upgrade Jest to 22 ([#109](https://github.com/thymikee/jest-preset-angular/pull/109))
* Breaking: Upgrade `ts-jest` to 22 ([#109](https://github.com/thymikee/jest-preset-angular/pull/109))
* Chore: Get rid of explicit `jsdom` dependency and custom test environment
* Fix: Upgrade example app to Angular 5.2.x using Angular CLI 1.6.6
* Fix: Add @types/jest as a package dependency
* Fix: Adjust README for easy installation guide and add configuration section with vendor libaries like jQuery etc..
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move these to master change log and link to PT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean I should commit these changes to CHANGELOG.md on master branch and mention these changes with PR behind ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, by master I mean master changelog. The first line of this file states:

## Changelog (master)

Since these "fixes" are not part of v5.0.0 release, let's just move them up:

## Changelog (master)

* Feature: Simplify installation by adding @types/jest as a package dependency ([#116](...))
* Chore: Upgrade example app to Angular 5.2 using Angular CLI 1.6 ([#116](...))

### v5.0.0
**v5.0.0 stuff, do not touch**

And later with a followup PR:

* Docs: Add a configuration section with vendor libraries like jQuery ([#117](...))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok I got it


### v4.0.2
* Breaking: Change to MIT license ([#102](https://github.com/thymikee/jest-preset-angular/pull/102))
Expand Down
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ This is a part of the article: [Testing Angular faster with Jest](https://www.xf
## Installation

```bash
yarn add --dev jest jest-preset-angular @types/jest
yarn add -D jest jest-preset-angular
```

This will install `jest`, `@types/jest`, `ts-jest`, `jest-zone-patch` as dependencies needed to run with Angular projects.

## Usage
In `src` directory create `setupJest.ts` file with following contents:
```js
Expand Down Expand Up @@ -222,3 +224,22 @@ import 'rxjs/add/operator/catch';

import './jestGlobalMocks';
```

### Allow vendor libraries like jQuery, etc...
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we separate this into its own PR? I'd like not to mix unrelated changes in one shot

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I think that's better


The same like normal Jest configuration, you can load jQuery in your Jest setup file. For example your Jest setup file is `setupJest.ts` you can declare jQuery:

```
window.$ = require('path/to/jquery');
``

or

```
import $ from 'jquery';
global.$ = global.jQuery = $;
```

The same declaration can be applied to other vendor libraries.

Reference: https://github.com/facebook/jest/issues/708
41 changes: 20 additions & 21 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,38 @@
},
"private": true,
"dependencies": {
"@angular/animations": "^5.0.0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/router": "^5.0.0",
"core-js": "^2.4.1",
"rxjs": "^5.5.2",
"zone.js": "^0.8.18"
"@angular/animations": "^5.2.2",
"@angular/common": "^5.2.2",
"@angular/compiler": "^5.2.2",
"@angular/core": "^5.2.2",
"@angular/forms": "^5.2.2",
"@angular/http": "^5.2.2",
"@angular/platform-browser": "^5.2.2",
"@angular/platform-browser-dynamic": "^5.2.2",
"@angular/router": "^5.2.2",
"core-js": "^2.5.3",
"rxjs": "^5.5.6",
"zone.js": "^0.8.20"
},
"devDependencies": {
"@angular/cli": "1.6.1",
"@angular/compiler-cli": "^5.0.0",
"@types/jest": "^19.2.2",
"@angular/cli": "^1.6.6",
"@angular/compiler-cli": "^5.2.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"codelyzer": "^4.1.0",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"jest": "^22.1.2",
"jest-preset-angular": "^5.0.0-beta.0",
"jest": "^22.1.4",
"jest-preset-angular": "^5.0.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2"
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
},
"jest": {
"preset": "jest-preset-angular",
Expand Down
Loading