Skip to content

Commit

Permalink
feat!: update aria-live-capture to ESM-only version
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed May 12, 2024
1 parent f604644 commit cbb9f3f
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 17 deletions.
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,46 +70,52 @@ npm install --save-dev extend-to-be-announced

### Test setup

There are out-of-the-box setups for Jest and Vitest.
There are out-of-the-box setups for Vitest and Jest.

#### Jest
#### Vitest

Import registration entrypoint in your [test setup](https://jestjs.io/docs/en/configuration.html#setupfilesafterenv-array).
Import registration entrypoint in your [test setup](https://vitest.dev/config/#setupfiles).

```js
import 'extend-to-be-announced/jest';
import 'extend-to-be-announced/vitest';
```

For setting up registration options use `register(options)` method instead.

```js
import { register } from 'extend-to-be-announced/jest/register';
import { register } from 'extend-to-be-announced/vitest/register';

register({
/** Indicates whether live regions inside `ShadowRoot`s should be tracked. Defaults to false. */
includeShadowDom: true,
});
```

#### Vitest
#### Jest

Import registration entrypoint in your [test setup](https://vitest.dev/config/#setupfiles).
Import registration entrypoint in your [test setup](https://jestjs.io/docs/en/configuration.html#setupfilesafterenv-array).

```js
import 'extend-to-be-announced/vitest';
import 'extend-to-be-announced/jest';
```

For setting up registration options use `register(options)` method instead.

```js
import { register } from 'extend-to-be-announced/vitest/register';
import { register } from 'extend-to-be-announced/jest/register';

register({
/** Indicates whether live regions inside `ShadowRoot`s should be tracked. Defaults to false. */
includeShadowDom: true,
});
```

Note that you'll need to add ESM dependencies of this package to your Jest config's `transformIgnorePatterns`. For example with `pnpm`:

```js
transformIgnorePatterns: ['/node_modules/.pnpm/(?!(aria-live-capture)@)'],
```

### Typescript

This package utilizes [Typescript's `exports` support](https://www.typescriptlang.org/docs/handbook/esm-node.html#packagejson-exports-imports-and-self-referencing) for type declarations. You'll need to set `"moduleResolution": "node16"` or `"moduleResolution": "nodenext"` in your `tsconfig.json` in order to have typings picked properly. For legacy setups where certain fields of `tsconfig.json` cannot be modified, such as `create-react-app`, there is a work-around entrypoint for `jest`.
Expand Down
5 changes: 5 additions & 0 deletions examples/example-create-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,10 @@
"react-dom": "^18.2.0",
"react-scripts": "^5.0.1",
"typescript": "^4.9.4"
},
"jest": {
"transformIgnorePatterns": [
"/node_modules/.pnpm/(?!(aria-live-capture)@)"
]
}
}
3 changes: 2 additions & 1 deletion examples/example-jest-shadow-dom/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
preset: 'ts-jest/presets/js-with-ts',
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['./setup.ts'],
transformIgnorePatterns: ['/node_modules/.pnpm/(?!(aria-live-capture)@)'],
};
1 change: 1 addition & 0 deletions examples/example-jest-shadow-dom/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"module": "CommonJS",
"target": "ESNext",
"moduleResolution": "Node16",
"allowJs": true,
"noEmit": true,
"skipLibCheck": true
}
Expand Down
3 changes: 2 additions & 1 deletion examples/example-jest/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
preset: 'ts-jest/presets/js-with-ts',
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['./setup.ts'],
transformIgnorePatterns: ['/node_modules/.pnpm/(?!(aria-live-capture)@)'],
};
1 change: 1 addition & 0 deletions examples/example-jest/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"module": "CommonJS",
"target": "ESNext",
"moduleResolution": "Node16",
"allowJs": true,
"noEmit": true,
"skipLibCheck": true
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"homepage": "https://github.com/AriPerkkio/extend-to-be-announced",
"bugs": "https://github.com/AriPerkkio/extend-to-be-announced",
"dependencies": {
"aria-live-capture": "^1.0.2"
"aria-live-capture": "^2.0.0"
},
"devDependencies": {
"@eslint/js": "^9.2.0",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cbb9f3f

Please sign in to comment.