Skip to content

Commit

Permalink
refactor: remove rollup implementation of transform plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Dec 1, 2023
1 parent 841d5b2 commit 7134596
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"lint:fix": "eslint --ext .vue,.ts,.js,.mjs . --fix",
"test:examples": "pnpm -r test",
"test:types": "vue-tsc --noEmit",
"test:unit": "vitest test/unit --run",
"prepack": "unbuild",
"dev:prepare": "nuxi prepare && unbuild --stub && pnpm -r dev:prepare",
"release": "pnpm test:examples && pnpm build && changelogen --release --push && pnpm publish"
Expand Down
2 changes: 0 additions & 2 deletions src/module/plugins/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,6 @@ export const createMockPlugin = (ctx: MockPluginContext) => createUnplugin(() =>
}
},
},
// purely for unit testing
rollup: { transform },
}
})

Expand Down
18 changes: 9 additions & 9 deletions test/unit/mock-transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('mocking', () => {
resolveId: (id) => id === input ? input : { id, external: true },
load: () => code
},
plugin.rollup(),
plugin.vite(),
{
name: 'resolve',
transform: {
Expand Down Expand Up @@ -50,10 +50,10 @@ describe('mocking', () => {
`)).toMatchInlineSnapshot(`
"import {vi} from \\"vitest\\";
vi.hoisted(() => {
if(!global.__NUXT_VITEST_MOCKS){
vi.stubGlobal(\\"__NUXT_VITEST_MOCKS\\", {})
}
});
if(!global.__NUXT_VITEST_MOCKS){
vi.stubGlobal(\\"__NUXT_VITEST_MOCKS\\", {})
}
});
vi.mock(\\"bob\\", async (importOriginal) => {
const mocks = global.__NUXT_VITEST_MOCKS
if (!mocks[\\"bob\\"]) { mocks[\\"bob\\"] = { ...await importOriginal(\\"bob\\") } }
Expand Down Expand Up @@ -100,10 +100,10 @@ describe('mocking', () => {
`)).toMatchInlineSnapshot(`
"import {vi} from \\"vitest\\";
vi.hoisted(() => {
if(!global.__NUXT_VITEST_MOCKS){
vi.stubGlobal(\\"__NUXT_VITEST_MOCKS\\", {})
}
});
if(!global.__NUXT_VITEST_MOCKS){
vi.stubGlobal(\\"__NUXT_VITEST_MOCKS\\", {})
}
});
vi.mock(\\"MyComponent\\", async () => {
const factory = (() => import('./MockComponent.vue'));
const result = typeof factory === 'function' ? await factory() : await factory
Expand Down

0 comments on commit 7134596

Please sign in to comment.