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

Tests: Added an option to accept the actual token stream #2515

Merged
merged 2 commits into from
Aug 17, 2020

Conversation

RunDevelopment
Copy link
Member

@RunDevelopment RunDevelopment commented Aug 10, 2020

Running npm run test:languages -- --accept will now insert the actual token stream of a test case to be the expect JSON. This will only be done if no expected JSON is specified.

Example

Test case:

var foo = 0;

Run npm run test:languages -- --accept.

Test case:

var foo = 0;

----------------------------------------------------

[
	["keyword", "var"],
	" foo ",
	["operator", "="],
	["number", "5"],
	["punctuation", ";"]
]

Motivation

This is super useful for creating many test cases at once.
When I create and change languages, I always have test drive open constantly check that every works. I then just copy the code from test drive I know work into test cases and copy their JSON from console output. This command makes my usual workflow a lot quicker.

It also makes it easier for first-time contributors to create test cases.


This resolves #2401.

test-suite.html Outdated Show resolved Hide resolved
@RunDevelopment RunDevelopment merged commit bafab63 into PrismJS:master Aug 17, 2020
@RunDevelopment RunDevelopment deleted the test-case-accept branch August 17, 2020 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically generate expected JSON for .test files
2 participants