Skip to content

Commit 1bbad96

Browse files
committed
feat: pass options to JSDOM
1 parent df83fc8 commit 1bbad96

6 files changed

+47
-30
lines changed

.ncurc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"reject": ["standard"]
3+
}

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2.1.0] - 2022-10-21
8+
9+
### Added
10+
- Add ability to pass options to JSDOM in the `init` function
11+
712
## [2.0.0] - 2022-10-03
813

914
### Breaking

README.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,17 @@ import test from 'ava'
3030
import { init, render } from '@ficusjs/testing'
3131

3232
test.before(init)
33+
34+
// if passing options to JSDOM
35+
test.before(() => init({ runScripts: 'dangerously' }))
3336
```
3437

38+
The `init` function accepts the following optional arguments:
39+
40+
| Name | Type | Description |
41+
|------------|----------|---------------------------------------|
42+
| `options` | `object` | An object of options to pass to JSDOM |
43+
3544
### render function
3645

3746
The `render` function will create a new web component instance for testing.
@@ -52,9 +61,9 @@ test('render basic component', async t => {
5261

5362
The `render` function accepts the following arguments:
5463

55-
| Name | Type | Description |
56-
| --- | --- | --- |
57-
| `tagName` | `string` | The web component tag name |
64+
| Name | Type | Description |
65+
|------------|------------|------------------------------------------------------------------------|
66+
| `tagName` | `string` | The web component tag name |
5867
| `importer` | `function` | A function that registers a web component. This can return a `Promise` |
5968

6069
## Testing components

package-lock.json

+22-22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ficusjs/testing",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"description": "Helper functions for component testing",
55
"type": "module",
66
"main": "src/index.mjs",
@@ -31,8 +31,8 @@
3131
"jsdom": "20.0.1"
3232
},
3333
"devDependencies": {
34-
"@ficusjs/core": "1.4.0",
35-
"@ficusjs/renderers": "5.2.0",
34+
"@ficusjs/core": "2.0.0",
35+
"@ficusjs/renderers": "5.3.0",
3636
"ava": "4.3.3",
3737
"standard": "16.0.4"
3838
},

src/index.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { JSDOM } from 'jsdom'
22

3-
export function init () {
4-
const dom = new JSDOM('<!DOCTYPE html><html><head></head><body></body></html>')
3+
export function init (options = {}) {
4+
const dom = new JSDOM('<!DOCTYPE html><html><head></head><body></body></html>', options)
55
globalThis.dom = dom
66
globalThis.Node = dom.Node
77
globalThis.window = dom.window

0 commit comments

Comments
 (0)