-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Jest + Playwright Testing #1276
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
@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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jhildenbiddle Awesome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
1c365fb
# Conflicts: # cypress/fixtures/tpl/docs.index.html # docs/index.html # package-lock.json # test/unit/render.test.js
* develop: (81 commits) fix: upgrade dompurify from 2.1.0 to 2.1.1 (#1402) fix: upgrade dompurify from 2.0.17 to 2.1.0 (#1397) fix: search on homepage test (#1398) fix: the sidebar links to another site. (#1336) fix: Can't search homepage content (#1391) fix: upgrade debug from 4.1.1 to 4.3.0 (#1390) fix: packages/docsify-server-renderer/package.json & packages/docsify-server-renderer/package-lock.json to reduce vulnerabilities (#1389) Fix eslint warnings (#1388) docs: add crossOriginLinks configurations details. (#1386) Remove Cypress screenshots Fix friendly message display Add Vue 3 compatibility Show dir listing & help msg for manual instance Add NODE_MODULES_URL global Jest + Playwright Testing (#1276) update doc (#1381) Fix scroll event end value fix: upgrade docsify from 4.11.4 to 4.11.6 (#1373) chore(deps): bump node-fetch in /packages/docsify-server-renderer (#1370) test: fix cannot search list content (#1367) ...
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.js
and note that we are using Jestprojects
to 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.js
and/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: