KittyGiraudel / a11y-dialog

A very lightweight and flexible accessible modal dialog script.
https://a11y-dialog.netlify.app
MIT License
2.42k stars 130 forks source link

Set up some smoke tests for packaging #703

Closed KittyGiraudel closed 3 months ago

KittyGiraudel commented 3 months ago

@drwpow-figma I started with the approach you recommended in #702. It works perfectly fine for the CJS tests, but the ESM ones fail like this:

node:internal/process/esm_loader:34
      internalBinding('errors').triggerUncaughtException(
                                ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'a11y-dialog' imported from /Users/kitty/Sites/a11y-dialog/cypress/fixtures/esm/test.js
Did you mean to import a11y-dialog/cypress/fixtures/dist/a11y-dialog.esm.js?
    at packageResolve (node:internal/modules/esm/resolve:853:9)
    at moduleResolve (node:internal/modules/esm/resolve:910:20)
    at defaultResolve (node:internal/modules/esm/resolve:1130:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
    at link (node:internal/modules/esm/module_job:84:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Do you have an idea why?

drwpow-figma commented 3 months ago

Yes see comment above—we want to make sure we’re using the dist/ in the root, and not copying it anywhere else.

Or, if Cypress needs a special setup to make it happy, that’s fine. But the vanilla Node.js tests should be using the root dist folder, that way you’re sure you’re testing the package exactly as it ships to npm.