Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vuejs/vue-jest
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v29.2.4
Choose a base ref
...
head repository: vuejs/vue-jest
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v29.2.5
Choose a head ref
  • 2 commits
  • 8 files changed
  • 2 contributors

Commits on Aug 6, 2023

  1. fix: lang='tsx' doesn't work for Vue 3 SFC (#547)

    Applies the same fix for Vue 2 with this PR: #395
    
    Resolves #510
    sevilyilmaz authored Aug 6, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b3238b2 View commit details
  2. publish: 29.2.5

    lmiller1990 committed Aug 6, 2023
    Copy the full SHA
    d7a9494 View commit details
7 changes: 7 additions & 0 deletions e2e/3.x/babel-in-package/components/Tsx.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script lang="tsx">
export default {
setup() {
return () => <div>tsx components</div>
}
}
</script>
4 changes: 4 additions & 0 deletions e2e/3.x/babel-in-package/package.json
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@vue/babel-plugin-jsx": "^1.1.5",
"@vue/vue3-jest": "^29.0.0",
"coffeescript": "^2.3.2",
"jest": "29.x",
@@ -34,6 +35,9 @@
"babel": {
"presets": [
"@babel/env"
],
"plugins": [
"@vue/babel-plugin-jsx"
]
}
}
6 changes: 6 additions & 0 deletions e2e/3.x/babel-in-package/test.js
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ import { createApp, h } from 'vue'
import TypeScript from './components/TypeScript.vue'
import Basic from './components/Basic.vue'
import Coffee from './components/Coffee.vue'
import Tsx from './components/Tsx.vue'

function mount(Component, props, slots) {
document.getElementsByTagName('html')[0].innerHTML = ''
@@ -34,3 +35,8 @@ test('processes .vue files with lang set to typescript', () => {
expect(document.querySelector('#parent').textContent).toBe('Parent')
expect(document.querySelector('#child').textContent).toBe('Child')
})

test('processes .vue files with lang set to tsx(typescript)', () => {
mount(Tsx)
expect(document.querySelector('div').textContent).toContain('tsx components')
})
2 changes: 1 addition & 1 deletion packages/vue2-jest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/vue2-jest",
"version": "29.2.4",
"version": "29.2.5",
"description": "Jest transformer for Vue 2",
"main": "lib/index.js",
"files": [
2 changes: 1 addition & 1 deletion packages/vue3-jest/lib/process.js
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ const vueComponentNamespace = require('./constants').vueComponentNamespace
function resolveTransformer(lang = 'js', vueJestConfig) {
const transformer = getCustomTransformer(vueJestConfig['transform'], lang)
if (/^typescript$|tsx?$/.test(lang)) {
return transformer || typescriptTransformer
return transformer || typescriptTransformer(lang)
} else if (/^coffee$|coffeescript$/.test(lang)) {
return transformer || coffeescriptTransformer
} else {
6 changes: 3 additions & 3 deletions packages/vue3-jest/lib/transformers/typescript.js
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ const {
getVueJestConfig
} = require('../utils')

module.exports = {
module.exports = scriptLang => ({
process(scriptContent, filePath, config) {
ensureRequire('typescript', ['typescript'])
const typescript = require('typescript')
@@ -16,7 +16,7 @@ module.exports = {

const res = typescript.transpileModule(scriptContent, {
...tsconfig,
fileName: filePath
fileName: filePath + (scriptLang === 'tsx' ? '.tsx' : '')
})

res.outputText = stripInlineSourceMap(res.outputText)
@@ -31,4 +31,4 @@ module.exports = {

return transformer.process(res.outputText, filePath, config)
}
}
})
2 changes: 1 addition & 1 deletion packages/vue3-jest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/vue3-jest",
"version": "29.2.4",
"version": "29.2.5",
"description": "Jest Vue transform",
"main": "lib/index.js",
"files": [
189 changes: 186 additions & 3 deletions yarn.lock

Large diffs are not rendered by default.