Skip to content

Commit

Permalink
test: add injected importmap test
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Oct 21, 2024
1 parent de6f2ff commit 63f0c34
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ import { test, expect } from 'vitest';
test('custom', () => {
expect(window).toHaveProperty('CUSTOM_INJECTED', true)
})

test('importmap is injected', () => {
expect(import.meta.resolve('some-lib')).toBe('https://vitest.dev/some-lib')
})
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,23 @@ export default defineConfig({
name: 'test:html',
transformIndexHtml() {
return [
{
tag: 'script',
injectTo: 'head-prepend',
attrs: {
type: 'importmap'
},
children: JSON.stringify({
"imports": {
"some-lib": "https://vitest.dev/some-lib",
},
})
},
{
tag: 'script',
children: 'window.CUSTOM_INJECTED = true',
injectTo: 'head',
}
},
]
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ export default defineConfig({
name: 'test:html',
transformIndexHtml() {
return [
{
tag: 'script',
injectTo: 'head-prepend',
attrs: {
type: 'importmap'
},
children: JSON.stringify({
"imports": {
"some-lib": "https://vitest.dev/some-lib",
},
})
},
{
tag: 'script',
children: 'window.CUSTOM_INJECTED = true',
Expand Down

0 comments on commit 63f0c34

Please sign in to comment.