updats on the dispatch page
This commit is contained in:
19
tools/css-hooks.mjs
Normal file
19
tools/css-hooks.mjs
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Make `import './thing.css'` a no-op under the Node test runner.
|
||||
*
|
||||
* Vite turns a CSS import into a side effect that injects a stylesheet; Node
|
||||
* has no such notion and refuses the file outright with
|
||||
* ERR_UNKNOWN_FILE_EXTENSION. That is fine for the pure tests, which never
|
||||
* import a component — but the map has to be MOUNTED to be tested at all, and
|
||||
* leaflet's own stylesheet comes with it.
|
||||
*
|
||||
* Styling is not what those tests check. They count polylines and markers in
|
||||
* the document, which leaflet creates regardless of whether any CSS loaded. So
|
||||
* every `.css` specifier resolves to an empty module and the import vanishes.
|
||||
*/
|
||||
export function resolve(specifier, context, next) {
|
||||
if (specifier.endsWith('.css')) {
|
||||
return { url: 'data:text/javascript,export default {}', shortCircuit: true };
|
||||
}
|
||||
return next(specifier, context);
|
||||
}
|
||||
9
tools/stub-css.mjs
Normal file
9
tools/stub-css.mjs
Normal file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Registers the CSS stub for the test runner.
|
||||
*
|
||||
* Loaded with `node --import`, which has to happen before any test module is
|
||||
* evaluated — a hook registered later cannot intercept an import that has
|
||||
* already been resolved.
|
||||
*/
|
||||
import { register } from 'node:module';
|
||||
register('./css-hooks.mjs', import.meta.url);
|
||||
Reference in New Issue
Block a user