Skip to content

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.

@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