File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// - this exists because I'm not sure how to mock
22// the dynamic import function, so mocking this instead
3+ // (also, if it _is_ possible to mock the dynamic import,
4+ // there's the risk of altering/breaking the behavior of imports
5+ // across the board - including non-dynamic imports)
6+ //
37// - also, vitest has a limitation on mocking:
48// https://vitest.dev/guide/mocking/modules.html#mocking-modules-pitfalls
9+ //
510// - basically if a function is called by another function in the same file
611// it can't be mocked. So this was extracted into a separate file
12+ //
13+ // - one thing to note is vitest does the same thing here:
14+ // https://github.com/vitest-dev/vitest/blob/main/test/core/src/dynamic-import.ts
15+ // - and uses that with tests here:
16+ // https://github.com/vitest-dev/vitest/blob/main/test/core/test/mock-internals.test.ts#L27
17+ //
18+ // - so this looks like a reasonable approach
719export async function dynamicImport ( path : string ) {
820 return import ( path )
921}
Original file line number Diff line number Diff line change @@ -35,8 +35,10 @@ export async function findForUrl(
3535 rawFindings = await new AxeBuilder ( { page} ) . analyze ( )
3636 }
3737
38- // - this condition is not required, but makes it easier to make assertions
39- // in unit tests on whether 'loadPlugins' was called or not
38+ // - this if condition is not required, but makes it easier to make assertions
39+ // in unit tests on whether 'loadPlugins' was called or not (it does have the added
40+ // benefit of completely skipping plugin loading if we just want axe - so thats
41+ // a minor performance boost)
4042 // - alternatively, we can wrap the 'plugin.default(...)' call in another function
4143 // and make assertions on whether that function was called or not
4244 // - the other option is to wrap each plugin in a class instance
You can’t perform that action at this time.
0 commit comments