Skip to content

Commit

Permalink
feat: ships jest transformer, close #8
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Aug 24, 2021
1 parent 1af58c7 commit f09aae6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,25 @@ module.exports = {

<br></details>


<details>
<summary>Jest</summary><br>

```bash
npm i -D vue-jest
```

```ts
// jest.config.js
module.exports = {
transform: {
'.*\\.(vue)$': 'unplugin-vue2-script-setup/jest',
},
}
```

<br></details>

<details>
<summary>JavaScript API</summary><br>

Expand Down
9 changes: 9 additions & 0 deletions jest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const { transform } = require('./dist/index')

module.exports = {
process(source, filename, ...args) {
const transformed = transform(source, filename)
return require('vue-jest').process.call(this, transformed.code, filename, ...args)
},
}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"require": "./dist/nuxt.js",
"import": "./dist/nuxt.mjs"
},
"./jest": {
"require": "./jest.js"
},
"./types": {
"require": "./dist/types.js",
"import": "./dist/types.mjs"
Expand All @@ -46,6 +49,7 @@
"keywords": [],
"files": [
"dist",
"jest.js",
"*.d.ts"
],
"scripts": {
Expand Down

0 comments on commit f09aae6

Please sign in to comment.