-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: register all auto-imports for mocking (#254)
Co-authored-by: Ghazi <ghazialhouwari@gmail.com>
- Loading branch information
1 parent
73dc976
commit 69ed723
Showing
4 changed files
with
37 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,23 @@ | ||
import { defineNuxtModule } from '@nuxt/kit' | ||
import { defineNuxtModule, createResolver, addImports } from '@nuxt/kit' | ||
|
||
export default defineNuxtModule({ | ||
meta: { | ||
name: 'custom', | ||
}, | ||
setup(_, _nuxt) { | ||
console.log('From custom module!') | ||
}, | ||
|
||
const { resolve } = createResolver(import.meta.url) | ||
|
||
addImports([ | ||
{ | ||
name: 'useCustomModuleAutoImportedTarget', | ||
from: resolve('runtime/composables/auto-import-mock') | ||
}, | ||
{ | ||
name: 'useCustomModuleAutoImportedNonTarget', | ||
from: resolve('runtime/composables/auto-import-mock') | ||
} | ||
]) | ||
} | ||
}) |
7 changes: 7 additions & 0 deletions
7
test/fixtures/nuxt-vitest/modules/runtime/composables/auto-import-mock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export function useCustomModuleAutoImportedTarget() { | ||
return 'the original' | ||
} | ||
|
||
export function useCustomModuleAutoImportedNonTarget() { | ||
return 'the original' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters