You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've added '@nuxt/test-utils/module', in nuxt.config.ts file
Added a scripts entry: "test": "vitest --config ./vitest.config.js run", in package.json file
Also added a vitest.config.ts file with following content:
`import { defineVitestConfig } from '@nuxt/test-utils/config';
export default defineVitestConfig({
test: {
environment: 'nuxt',
environmentOptions: {
nuxt: {
mock: {
intersectionObserver: true,
indexedDb: true,
},
},
},
},
}); And also wrote a following test case:import { expect, describe, test } from 'vitest';
import SideNav from '~/components/SideNav.vue';
import { mountSuspended } from '@nuxt/test-utils/runtime';
describe('SideNav', () => {
test('mounts', async () => {
const component = await mountSuspended(SideNav);
expect(component.text()).toContain('Home');
});
});
`
Located on path: /home/arajkovic/workspace/work/portal/tests/components/SideNav.spec.ts (also tried pulling it out of components directory)
Tested component is located at : /home/arajkovic/workspace/work/portal/components/SideNav.SideNav.vue
Describe the bug
`arajkovic@RTRKA019-lin:~/workspace/work/portal$ pnpm test
nuxt-app@ test /home/arajkovic/workspace/work/portal
vitest --config ./vitest.config.js run
RUN v2.1.8 /home/arajkovic/workspace/work/portal
`
Execution is getting stuck here, no test is ever run.
Additional context
I've also tried adding plugins: [vue()] and changing test environment to happy-dom but in that case I get random errors which do not make sense (some page does not contain template or script tags even tho they do), example:
FAIL tests/components/SideNav.nuxt.spec.ts [ tests/components/SideNav.nuxt.spec.ts ]
SyntaxError: At least one or <script> is required in a single file component. /home/arajkovic/workspace/work/portal/pages/engineering.vue
Am I missing something or I've encountered some kind of a bug? I am stuck on this, seemingly basic, problem for 2 days now... Thanks in advance
Logs
The text was updated successfully, but these errors were encountered:
Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.
What will happen?
If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect.
If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.
How can I create a reproduction?
We have a couple of templates for starting with a minimal reproduction:
Environment
Working directory: /home/arajkovic/workspace/work/portal 1:45:56 PM
Nuxt project info: 1:45:56 PM
Reproduction
I've added '@nuxt/test-utils/module', in nuxt.config.ts file
Added a scripts entry: "test": "vitest --config ./vitest.config.js run", in package.json file
Also added a vitest.config.ts file with following content:
`import { defineVitestConfig } from '@nuxt/test-utils/config';
export default defineVitestConfig({
test: {
environment: 'nuxt',
environmentOptions: {
nuxt: {
mock: {
intersectionObserver: true,
indexedDb: true,
},
},
},
},
});
And also wrote a following test case:
import { expect, describe, test } from 'vitest';import SideNav from '~/components/SideNav.vue';
import { mountSuspended } from '@nuxt/test-utils/runtime';
describe('SideNav', () => {
test('mounts', async () => {
const component = await mountSuspended(SideNav);
expect(component.text()).toContain('Home');
});
});
`
Located on path: /home/arajkovic/workspace/work/portal/tests/components/SideNav.spec.ts (also tried pulling it out of components directory)
Tested component is located at : /home/arajkovic/workspace/work/portal/components/SideNav.SideNav.vue
Describe the bug
`arajkovic@RTRKA019-lin:~/workspace/work/portal$ pnpm test
RUN v2.1.8 /home/arajkovic/workspace/work/portal
`
Execution is getting stuck here, no test is ever run.
Additional context
I've also tried adding plugins: [vue()] and changing test environment to happy-dom but in that case I get random errors which do not make sense (some page does not contain template or script tags even tho they do), example:
FAIL tests/components/SideNav.nuxt.spec.ts [ tests/components/SideNav.nuxt.spec.ts ]
SyntaxError: At least one or <script> is required in a single file component. /home/arajkovic/workspace/work/portal/pages/engineering.vue
Am I missing something or I've encountered some kind of a bug? I am stuck on this, seemingly basic, problem for 2 days now... Thanks in advance
Logs
The text was updated successfully, but these errors were encountered: