From 8e9d860f9fbadf14c98e48634e259037db5bfdbe Mon Sep 17 00:00:00 2001 From: Ahn Date: Sat, 27 Jan 2018 19:45:19 +0100 Subject: [PATCH] Add documentation to support testing with vendor libraries (#117) --- CHANGELOG.md | 1 + README.md | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d15679a82..8c73b61510 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Changelog (master) * Feature: Simplify installation by adding @types/jest as a package dependency ([#116](https://github.com/thymikee/jest-preset-angular/pull/116)) * Chore: Upgrade example app to Angular 5.2 using Angular CLI 1.6 ([#116](https://github.com/thymikee/jest-preset-angular/pull/116)) +* Docs: Add a configuration section with vendor libraries like jQuery ([#117](https://github.com/thymikee/jest-preset-angular/pull/117)) ### v5.0.0 * Breaking: Upgrade Jest to 22 ([#109](https://github.com/thymikee/jest-preset-angular/pull/109)) diff --git a/README.md b/README.md index d2e8055f0d..86a2d3a752 100644 --- a/README.md +++ b/README.md @@ -224,3 +224,22 @@ import 'rxjs/add/operator/catch'; import './jestGlobalMocks'; ``` + +### Allow vendor libraries like jQuery, etc... + +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