Skip to content

Commit

Permalink
feat: includes browser deps if supported transform enabled
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Previously this plugin would never include browser dependencies including  files.
  • Loading branch information
DylanPiercey committed May 12, 2020
1 parent 359dd29 commit 01db282
Show file tree
Hide file tree
Showing 11 changed files with 625 additions and 3 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ module.exports = {
};
```

## Including `style` files

Since jest is uses JSDOM, which has limited support for stylesheets, including styles in the page often does not add a ton of value. However in some cases it can be useful to include these styles, for example with [visual-html](https://github.com/ebay/visual-html) or [jsdom-screenshot](https://github.com/dferber90/jsdom-screenshot).

This plugin will automatically include any Marko dependencies, including style files, if an appropriate jest transform is available.
To have Marko include a `style.css` file you could add [jest-transform-css](https://github.com/dferber90/jest-transform-css) to your `jest.config.js`.

## Why override the resolver (enhanced-resolve-jest)?

The default jest resolver does actually work fine with Marko when running server side tests, however in the browser they rely on [browser-resolve](https://github.com/shtylman/node-browser-resolve#readme). The browser resolver then relies on a version of [resolve](https://github.com/browserify/resolve) which is over three years old and has had many fixes since.
Expand Down
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const base = {
preset: "./jest-preset",
transform: {
"\\.ts$": "ts-jest"
"\\.ts$": "ts-jest",
"\\.css$": "jest-transform-css"
}
};

Expand Down
Loading

0 comments on commit 01db282

Please sign in to comment.