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

chore: implement @puppeteer/doctest #10933

Merged
merged 1 commit into from Sep 19, 2023
Merged

chore: implement @puppeteer/doctest #10933

merged 1 commit into from Sep 19, 2023

Conversation

jrandolf
Copy link
Contributor

@jrandolf jrandolf commented Sep 18, 2023

This PR implements a documentation example tester, similar to the one in Rust.

Usage

npm run doctest

Details

@puppeteer/doctest looks through compiled code for @example comments with fenced code blocks. It will then parse out the code within the fence and run it using Node's test runner.

The first line containing the starting fence defines the options for a given fenced code block. For example,

  • ```ts defines a TypeScript code block.
  • ``` defines a JavaScript code block.
  • ```ts ignore defines a TypeScript code block that is ignored for testing.

Note that

  • ``` ignore and
  • ```ignore

are different. The former is an ignored JS code block. The latter is a code block for the ignore language.

If there are several code blocks within an example, they are concatenated before running.

@jrandolf jrandolf force-pushed the jrandolf/doctest branch 14 times, most recently from f9d4077 to ccfbe6e Compare September 19, 2023 00:08
@OrKoN
Copy link
Collaborator

OrKoN commented Sep 19, 2023

I think it is a good idea, I will let @Lightning00Blade to do the review

test/TestExpectations.json Outdated Show resolved Hide resolved
@jrandolf jrandolf force-pushed the jrandolf/doctest branch 5 times, most recently from 9c64054 to 2eb5af9 Compare September 19, 2023 09:29
@jrandolf jrandolf changed the base branch from main to jrandolf/ls-grep September 19, 2023 09:29
Base automatically changed from jrandolf/ls-grep to main September 19, 2023 09:35
@jrandolf jrandolf force-pushed the jrandolf/doctest branch 3 times, most recently from 96f269d to 6aba40f Compare September 19, 2023 09:39
tools/doctest/package.json Show resolved Hide resolved
tools/doctest/src/doctest.ts Outdated Show resolved Hide resolved
tools/doctest/src/doctest.ts Outdated Show resolved Hide resolved
@jrandolf jrandolf force-pushed the jrandolf/doctest branch 2 times, most recently from b9bb0b4 to 034ccdd Compare September 19, 2023 10:36
@jrandolf jrandolf force-pushed the jrandolf/doctest branch 3 times, most recently from 3483c78 to c6aedea Compare September 19, 2023 10:55
package.json Outdated Show resolved Hide resolved
tools/doctest/package.json Show resolved Hide resolved
tools/doctest/src/doctest.ts Outdated Show resolved Hide resolved
tools/doctest/src/doctest.ts Outdated Show resolved Hide resolved
tools/doctest/src/doctest.ts Outdated Show resolved Hide resolved
@jrandolf jrandolf force-pushed the jrandolf/doctest branch 2 times, most recently from c3f736b to 74d7fdb Compare September 19, 2023 12:52
@jrandolf jrandolf force-pushed the jrandolf/doctest branch 7 times, most recently from d0fdf9e to 1dd00c2 Compare September 19, 2023 14:42
@jrandolf jrandolf merged commit 88e0997 into main Sep 19, 2023
28 of 36 checks passed
@jrandolf jrandolf deleted the jrandolf/doctest branch September 19, 2023 15:13
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 this pull request may close these issues.

None yet

3 participants