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.3
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.4
Choose a head ref
  • 3 commits
  • 5 files changed
  • 3 contributors

Commits on Mar 2, 2023

  1. publish: v29.2.3

    lmiller1990 committed Mar 2, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    21feab9 View commit details

Commits on Apr 27, 2023

  1. fix: script and script setup in same vue component file (Vue 3) (#541)

    Co-authored-by: qhermel <quentin.hermel@preventeo.com>
    quienti and qhermel authored Apr 27, 2023
    Copy the full SHA
    3605c5e View commit details
  2. publish: 29.2.4

    lmiller1990 committed Apr 27, 2023
    Copy the full SHA
    972e5aa View commit details
Showing with 40 additions and 4 deletions.
  1. +23 −0 e2e/3.x/basic/components/ScriptAndScriptSetup.vue
  2. +7 −0 e2e/3.x/basic/test.js
  3. +1 −1 packages/vue2-jest/package.json
  4. +8 −2 packages/vue3-jest/lib/process.js
  5. +1 −1 packages/vue3-jest/package.json
23 changes: 23 additions & 0 deletions e2e/3.x/basic/components/ScriptAndScriptSetup.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<div>
<button @click="increase">Products: {{ products }}</button>
<Basic />
<span>{{ msg }}</span>
</div>
</template>

<script>
import Basic from './Basic.vue'
</script>

<script setup>
import { ref } from 'vue'
const products = ref(10)
const greet = () => console.log('greet')
const increase = () => {
greet()
num.value++
}
const msg = 'hello world'
</script>
7 changes: 7 additions & 0 deletions e2e/3.x/basic/test.js
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ import ScriptSetupSugarRef from './components/ScriptSetupSugarRef.vue'
import FunctionalRenderFn from './components/FunctionalRenderFn.vue'
import CompilerDirective from './components/CompilerDirective.vue'
import ExtendedTsConfig from './components/ExtendedTsConfig.vue'
import ScriptAndScriptSetup from './components/ScriptAndScriptSetup.vue'

// TODO: JSX for Vue 3? TSX?
import Jsx from './components/Jsx.vue'
@@ -214,3 +215,9 @@ test('handles extended tsconfig.json files', () => {
const elm = document.querySelector('div')
expect(elm).toBeDefined()
})

test('processes SFC with both <script> and <script setup> in same component file', () => {
mount(ScriptAndScriptSetup)
expect(document.body.outerHTML).toContain('Products: 10')
expect(document.body.outerHTML).toContain('Welcome to Your Vue.js App')
})
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.2",
"version": "29.2.4",
"description": "Jest transformer for Vue 2",
"main": "lib/index.js",
"files": [
10 changes: 8 additions & 2 deletions packages/vue3-jest/lib/process.js
Original file line number Diff line number Diff line change
@@ -164,15 +164,21 @@ module.exports = function(src, filename, config) {
getVueJestConfig(config)['componentNamespace'] || vueComponentNamespace

const templateResult = processTemplate(descriptor, filename, config)
const scriptResult = processScript(descriptor.script, filename, config)
const scriptSetupResult = processScriptSetup(descriptor, filename, config)
const stylesResult = processStyle(descriptor.styles, filename, config)
const customBlocksResult = processCustomBlocks(
descriptor.customBlocks,
filename,
componentNamespace,
config
)

let scriptResult
const scriptSetupResult = processScriptSetup(descriptor, filename, config)

if (!scriptSetupResult) {
scriptResult = processScript(descriptor.script, filename, config)
}

const output = generateCode({
scriptResult,
scriptSetupResult,
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.2",
"version": "29.2.4",
"description": "Jest Vue transform",
"main": "lib/index.js",
"files": [