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
  • Loading branch information
Coly010 committed May 16, 2024
1 parent e9bf1a2 commit 381e5cd
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 381e5cd

Please sign in to comment.