• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mbland / tomcat-servlet-testing-example / 6854515217
100%

Build:
DEFAULT BRANCH: main
Ran 13 Nov 2023 07:03PM UTC
Jobs 1
Files 1
Run time –
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

13 Nov 2023 06:47PM UTC coverage: 100.0%. Remained the same
6854515217

push

github

mbland
Add ESLint, Vitest, JSDOM+ESM workaround, JS test

Includes a workaround for JSDOM's current lack of <script type="module">
support, specifically when loading a HTML file:

- https://github.com/jsdom/jsdom/issues/2475

The importModules() helper method uses dynamic import() to apply
JavaScript modules after JSDOM has parsed, but not executed,
<script type="module"> elements.

The comments for importModules() and loadFromFile(), both currently in
main.test.js, contain further explanation.

(I may eventually extract these into a helper module, post them to the
aforementioned issue, write a blog post about them, etc.)

---

This problem arose because Vite depends on browser support for
JavaScript modules (a.k.a. ES modules):

- https://vitejs.dev/guide/build.html#browser-compatibility
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
- https://nodejs.org/dist/latest-v20.x/docs/api/esm.html

The Vitest "Hello, World!" test currently uses JSDOM to emulate a
browser (I'll add Vitest experimental browser support shortly):

- https://github.com/jsdom/jsdom

However, it took me a few hours to figure out that JSDOM parses, but
doesn't execute, `<script type="module">`, which is essential to how
Vite works:

- https://vitejs.dev/guide/#index-html-and-project-root

My original solution was to also include a `<script nomodule>` element
to load the same file, but that wasn't ideal. It also broke down when I
split `initApp` into init.js to force main.js to declare an `import`
statement.

The importModules() solution is far more robust. Given the constraints
with regard to event listeners mentioned in its function comment, it
provides a seamless solution. As described by the loadFromFile()
comment, when JSDOM supports <script type="module">, removal of
importModules() should prove straightforward.

5 of 5 relevant lines covered (100.0%)

2.8 hits per line

Jobs
ID Job ID Ran Files Coverage
1 6854515217.1 13 Nov 2023 07:03PM UTC 0
100.0
GitHub Action Run
Source Files on build 6854515217
Detailed source file information is not available for this build.
  • Back to Repo
  • Github Actions Build #6854515217
  • c7aa7e5c on github
  • Prev Build on main (#6817559520)
  • Next Build on main (#6856900955)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc