Conversation
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/docsify-core/docsify-preview/fs42flso2 |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit d58b3ad:
|
|
Nice! I will take a look this weekend! |
- Setup projects for e2e, integration, and unit tests in Jest configuration - Setup /tests/e2e/ tests for Jest+PlayWright - Setup /tests/integration/ tests for Jest - Setup /tests/unit/ tests for Jest - Setup eslint for Jest and Jest+Playwright environments - Move e2e configuration files into separate folder - Update e2e example tests - Update unit example tests - Update HTML fixtures
- Add `debug` option - Append `Markdown` suffix to markdown-related options - Reorder options alphabetically
…2e only) - Create identical docsifyInit() tests using Jest (integration) and Playwright (e2e) - Update docsifyInit() to convert relative URLs to absolute URLs to work in both JSDOM and Playwright - Update docsifyInit() to append style- and js-related tags using createElement instead of insertAdjacentHTML - Update paths in test files to use unified docsifyInit() - Added option to docsifyInit() to enable/disable formatted HTML output to console - Removed vue.css as default docsify theme from docsifyInit() - Removed outdated files
- Allows mocking all XMLHttpRequests instead of just those initiated via /src/core/fetch/ajax.js - Allows JSDOM tests to use /lib/docsify.js instead of /src/core/index.js (same as Playwright tests) - Allows JSDOM tests to use /docs site as test content
|
All done. :) Feel free to kick the tires and let me know what you think. Note the updated details in the first comment as well. I have noticed that this branch tends to get stuck on the "build (10.x)" task. This is odd, since it appears as though GitHub is not picking up the changes I made to our CI workflows: https://github.com/docsifyjs/docsify/tree/jest-playwright/.github/workflows. Not sure what's happening there. For now, you can check out the branch, update/install the necessary dependencies, and we can wrap up the review. |
- Import globals from various files instead of manually adding them to ensure they are availability in Jest and eslint configurations - Add middleware to server configuration for serving virtual “_blank.html” file - Add BLANK_URL - Rename TEST_URL to TEST_HOST - Removed ./test/fixtures/ directory (blank page now served via server.js middleware) - Added page.goto(BLANK_URL) call to global Playwright beforeEach() setup
|
@anikethsaha --
Yep. The Cypress tests we had were limited (only tested sidebar links on /doc site which we can do much more easily with snapshots), slow, and brittle. There's no reason to hang on to the tests or the dependencies.
GitHub Actions have already been updated in this PR. Unfortunately, the workflows aren't running because of GitHub issue that prevents workflows from running on PRs that have merge conflicts. The conflicts that need to be resolved are very minor and easily resolved. Once resolved and merged, workflows should run as expected.
Jest comes with jsdom baked in. No need for a separate jsdom dependency or import. |
|
@sy-records --
I just flipped the PR from "draft" to "ready". Can you approve the PR if everything looks good? |
|
@anikethsaha --
I just flipped the PR from "draft" to "ready". Can you approve the PR if everything looks good? |
# Conflicts: # cypress/fixtures/tpl/docs.index.html # docs/index.html # package-lock.json # test/unit/render.test.js

Summary
Details
An implementation of Jest+Playwright. This setup offers a number of advantages over the existing test structures (mocha+chai+jsdom & Cypress):
docsifyInit()helper. This abstraction allows new docsify instances to be dynamically generated declaratively with a fraction of the code that would otherwise be required. It also removes the need to manage a large collection of fixture files (although you can use them if you prefer)./docs/on the local testing server, making it easy to use our documentation as fixtures without having to duplicate the content../lib/directory is also mapped to/lib/on the local testing server, making it easy to use the latest docsify JS and CSS.Changes have been made to the GitHub workflows to accommodate these changes:
ubuntu-latest), macOS (macos-latest), and Windows (windows-latest) on the three latest LTS versions of Node (10, 12, 14).Part of the motivation for doing this work was to allow me to create proper tests for #1271. The other part was to try and clean up our test configuration so that we can offer a reliable and easy-to-learn environment for devs to work in. I looked at our existing test structures and realized there was no way for me do what I needed to do easily without creating complex tests with repeated boilerplate code and a large number of fixtures. Specifically, testing #1271 requires multiple docsify configurations that must be run in a browser with and without additional third-party scripts (vue.js). With this setup, every custom docisfy test is between 8 and 11 lines of code and zero test-specific file fixtures.
A few tips for reviewers:
./test/directory. This means this PR can safely be merged and it will not affect existing tests./test/README.md. This file provides an overview of the test environments, global variables, and CLI commands available../jest.config.jsand note that we are using Jestprojectsto simplify unique environment configurations for unit, integration, and e2e tests../test/helpers/docsify-init.js. This helper greatly simplifies the process of creating dynamic docsify sites for individual tests./test/unit/example.test.jsand/test/integration/example.test.js./test/e2e/example.test.js./test/e2e/vue.test.js;describe()ortest()name)describe()ortest()name)What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
The PR fulfills these requirements:
fix #xxx[,#xxx], where "xxx" is the issue number)Fix #1217
You have tested in the following browsers: (Providing a detailed version will be better.)
If adding a new feature, the PR's description includes: