Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript tests #2462

Closed
mgeisler opened this issue Nov 12, 2024 · 1 comment · Fixed by #2471
Closed

JavaScript tests #2462

mgeisler opened this issue Nov 12, 2024 · 1 comment · Fixed by #2471
Assignees

Comments

@mgeisler
Copy link
Collaborator

mgeisler commented Nov 12, 2024

Today, we don't have any tests for the JavaScript code found in

This has caused bugs in the past (the playgrounds disappeared at some point) and it makes it hard to upgrade mdbook (because we need to merge in changes to book.js manually).

It would be very helpful to have tests for these files. This should be something we can run on the command line in GitHub CI. I think we need something which

  • We can run on pre-rendered HTML files. I envision us running mdbook build (for each language).
  • A headless browser would then be needed to inspect the pages.
  • We would need a unit testing framework of some sort.
@michael-kerscher
Copy link
Collaborator

I created a first demo in that pull request to open a discussion before investing more in that direction.

mgeisler added a commit that referenced this issue Dec 4, 2024
This is a first draft for a test framework for testing the JS part of
the book that is discussed in #2462

It is using [webdriverIO](https://webdriver.io/) and the webdriverIO
[Expect API](https://webdriver.io/docs/api/expect-webdriverio/) in
combination with [Mocha](https://mochajs.org/). WebdriverIO is taking
care of accessing the webpage with a real browser and can access the
state of the page so behavior can be asserted.

Currently only a small test for the speaker-notes implementation demos
the functionality.

The [Static Server
Service](https://webdriver.io/docs/static-server-service/) is used to
serve the book in a way that the test runner can access it.

A CI integration can look like https://webdriver.io/docs/githubactions/
and is implemented with a headless setup. In CI it uses the language
variable to set environment variable that configures where the built
book should be mounted from

---------

Co-authored-by: Martin Geisler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants