Skip to content

Commit

Permalink
fix(vue): ootb unit testing should work with --routing #19921 (#23441)
Browse files Browse the repository at this point in the history
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->
When generating a vue application with routing and testing, the test
setup is incorrect and fails

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
The test setup for vue applications with routing should work OOTB

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #19921

(cherry picked from commit 381e5cd)
  • Loading branch information
Coly010 authored and FrozenPandaz committed May 21, 2024
1 parent 82ae356 commit 264f8cf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ import { mount } from '@vue/test-utils';
import App from './App.vue';
describe('App', () => {
it('renders properly', () => {
it('renders properly', async () => {
const wrapper = mount(App, {});
expect(wrapper.text()).toContain('Welcome test 👋');
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<% if ( unitTestRunner === 'vitest' ) { %>
import { describe, it, expect } from 'vitest'
<% } %><% if( routing ) { %>
import router from '../router';
<% } %>
import { mount } from '@vue/test-utils'
import App from './App.vue';

describe('App', () => {
it('renders properly', () => {
const wrapper = mount(App, {})
it('renders properly', async () => {
const wrapper = mount(App, <% if( routing ) { %>{ global: { plugins: [router] }}<% } else { %>{}<% } %>)
<% if( routing ) { %>
await router.isReady();
<% } %>
expect(wrapper.text()).toContain('Welcome <%= title %> 👋')
})
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import NxWelcome from '../app/NxWelcome.vue'

<template>
<main>
<NxWelcome />
<NxWelcome title="<%= title %>" />
</main>
</template>

0 comments on commit 264f8cf

Please sign in to comment.