Skip to content

Commit

Permalink
build!: use /runtime subpath export
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Dec 9, 2023
1 parent c580600 commit de9a2a8
Show file tree
Hide file tree
Showing 21 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, it, vi } from 'vitest'
import { mockNuxtImport } from '@nuxt/test-utils/runtime-utils'
import { mockNuxtImport } from '@nuxt/test-utils/runtime'

mockNuxtImport<typeof useAutoImportedTarget>('useAutoImportedTarget', () => {
return () => 'mocked!'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, it } from 'vitest'
import { mockComponent, mountSuspended } from '@nuxt/test-utils/runtime-utils'
import { mockComponent, mountSuspended } from '@nuxt/test-utils/runtime'
import App from '~/app.vue'

mockComponent('SomeComponent', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, it } from 'vitest'
import { mockComponent, mountSuspended } from '@nuxt/test-utils/runtime-utils'
import { mockComponent, mountSuspended } from '@nuxt/test-utils/runtime'
import App from '~/app.vue'

mockComponent('SomeComponent', () => import('./mocks/MockComponent.vue'))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, it } from 'vitest'
import { mockComponent, mountSuspended } from '@nuxt/test-utils/runtime-utils'
import { mockComponent, mountSuspended } from '@nuxt/test-utils/runtime'
import { SomeComponent } from '#components'

mockComponent('SomeComponent', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, it } from 'vitest'
import { mountSuspended } from '@nuxt/test-utils/runtime-utils'
import { mountSuspended } from '@nuxt/test-utils/runtime'
import MockComponent from './mocks/MockComponent.vue'

it('should expose setup state', async () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/app-vitest-full/tests/nuxt/mock-indexeddb.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, it } from 'vitest'
import { mountSuspended } from '@nuxt/test-utils/runtime-utils'
import { mountSuspended } from '@nuxt/test-utils/runtime'
import IndexedDbComponent from '~/components/IndexedDbComponent.vue'

// Mocking of indexedDB can be enabled in vite.config.ts
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, it } from 'vitest'
import { mockNuxtImport } from '@nuxt/test-utils/runtime-utils'
import { mockNuxtImport } from '@nuxt/test-utils/runtime'

mockNuxtImport('useRuntimeConfig', () => {
return () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, it } from 'vitest'
import { mockNuxtImport } from '@nuxt/test-utils/runtime-utils'
import { mockNuxtImport } from '@nuxt/test-utils/runtime'

mockNuxtImport('useHead', () => {
return () => true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, it } from 'vitest'
import { mockNuxtImport } from '@nuxt/test-utils/runtime-utils'
import { mockNuxtImport } from '@nuxt/test-utils/runtime'

mockNuxtImport('useAutoImportedTarget', () => {
return () => 'mocked'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, it } from 'vitest'

import { mountSuspended } from '@nuxt/test-utils/runtime-utils'
import { mountSuspended } from '@nuxt/test-utils/runtime'

import App from '~/app.vue'
import OptionsComponent from '~/components/OptionsComponent.vue'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it } from 'vitest'
import { renderSuspended } from '@nuxt/test-utils/runtime-utils'
import { renderSuspended } from '@nuxt/test-utils/runtime'
import { cleanup, fireEvent, screen } from '@testing-library/vue'

import App from '~/app.vue'
Expand Down
2 changes: 1 addition & 1 deletion examples/app-vitest-full/tests/nuxt/routing.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'

import { mountSuspended } from '@nuxt/test-utils/runtime-utils'
import { mountSuspended } from '@nuxt/test-utils/runtime'

import App from '~/app.vue'

Expand Down
2 changes: 1 addition & 1 deletion examples/app-vitest-full/tests/nuxt/server.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'

import { mountSuspended, registerEndpoint } from '@nuxt/test-utils/runtime-utils'
import { mountSuspended, registerEndpoint } from '@nuxt/test-utils/runtime'

import { listen } from 'listhen'
import { createApp, eventHandler, toNodeListener } from 'h3'
Expand Down
2 changes: 1 addition & 1 deletion examples/app-vitest-full/tests/setup/mocks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { vi } from 'vitest'
import { mockNuxtImport } from '@nuxt/test-utils/runtime-utils'
import { mockNuxtImport } from '@nuxt/test-utils/runtime'

mockNuxtImport<typeof useAutoImportSetupMocked>(
'useAutoImportSetupMocked',
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
"./config": "./dist/config.mjs",
"./experimental": "./dist/experimental.mjs",
"./module": "./dist/module.mjs",
"./runtime-utils": "./dist/runtime-utils/index.mjs",
"./runtime": "./dist/runtime-utils/index.mjs",
"./vitest-environment": "./dist/vitest-environment.mjs"
},
"files": [
"dist",
"config.d.ts",
"experimental.d.ts",
"module.d.ts",
"runtime-utils.d.ts",
"runtime.d.ts",
"vitest-environment.d.ts"
],
"scripts": {
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/runtime-utils/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type OptionalFunction<T> = T | (() => Awaitable<T>)
* @param options - factory function that returns the mocked data or an object containing both the `handler` and the `method` properties.
* @example
* ```ts
* import { registerEndpoint } from '@nuxt/test-utils/runtime-utils'
* import { registerEndpoint } from '@nuxt/test-utils/runtime'
*
* registerEndpoint("/test/", () => {
* test: "test-field"
Expand Down Expand Up @@ -69,7 +69,7 @@ export function registerEndpoint(
* @param _factory - factory function that returns mocked import.
* @example
* ```ts
* import { mockNuxtImport } from '@nuxt/test-utils/runtime-utils'
* import { mockNuxtImport } from '@nuxt/test-utils/runtime'
*
* mockNuxtImport('useStorage', () => {
* return () => {
Expand All @@ -94,7 +94,7 @@ export function mockNuxtImport<T = any>(
* @param setup - factory function that returns the mocked component.
* @example
* ```ts
* import { mockComponent } from '@nuxt/test-utils/runtime-utils'
* import { mockComponent } from '@nuxt/test-utils/runtime'
*
* mockComponent('MyComponent', {
* props: {
Expand Down
4 changes: 2 additions & 2 deletions src/runtime-utils/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const WRAPPER_EL_ID = 'test-wrapper'
*
* ```ts
* // tests/components/SomeComponents.nuxt.spec.ts
* import { renderSuspended } from '@nuxt/test-utils/runtime-utils'
* import { renderSuspended } from '@nuxt/test-utils/runtime'
*
* it('can render some component', async () => {
* const { html } = await renderSuspended(SomeComponent)
Expand All @@ -40,7 +40,7 @@ export const WRAPPER_EL_ID = 'test-wrapper'
* })
*
* // tests/App.nuxt.spec.ts
* import { renderSuspended } from '@nuxt/test-utils/runtime-utils'
* import { renderSuspended } from '@nuxt/test-utils/runtime'
* import { screen } from '@testing-library/vue'
*
* it('can also mount an app', async () => {
Expand Down
2 changes: 1 addition & 1 deletion stubs/vitest-environment-nuxt/utils.mjs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from '@nuxt/test-utils/runtime-utils'
export * from '@nuxt/test-utils/runtime'
8 changes: 4 additions & 4 deletions test/unit/mock-transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('mocking', () => {
from: 'bob'
}]
expect(await getResult(`
import { mockNuxtImport } from '@nuxt/test-utils/runtime-utils'
import { mockNuxtImport } from '@nuxt/test-utils/runtime'
mockNuxtImport('useSomeExport', () => {
return () => 'mocked'
})
Expand All @@ -65,7 +65,7 @@ describe('mocking', () => {
return mocks["bob"]
});
import { mockNuxtImport } from '@nuxt/test-utils/runtime-utils'
import { mockNuxtImport } from '@nuxt/test-utils/runtime'
import "bob";"
Expand Down Expand Up @@ -97,7 +97,7 @@ describe('mocking', () => {
filePath: '/test/thing.vue'
}]
expect(await getResult(`
import { mockComponent } from '@nuxt/test-utils/runtime-utils'
import { mockComponent } from '@nuxt/test-utils/runtime'
mockComponent('MyComponent', () => import('./MockComponent.vue'))
`)).toMatchInlineSnapshot(`
"import {vi} from "vitest";
Expand All @@ -112,7 +112,7 @@ describe('mocking', () => {
return 'default' in result ? result : { default: result }
});
import { mockComponent } from '@nuxt/test-utils/runtime-utils'
import { mockComponent } from '@nuxt/test-utils/runtime'
"
`)
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"config.d.ts",
"experimental.d.ts",
"module.d.ts",
"runtime-utils.d.ts",
"runtime.d.ts",
"vitest-environment.d.ts",
"dist/**",
"examples/*",
Expand Down

0 comments on commit de9a2a8

Please sign in to comment.