Skip to content

Commit 05024a6

Browse files
authored
[chore] add snapshot tests for syntax highlight grammar (#1391)
1 parent 5dfefc1 commit 05024a6

File tree

75 files changed

+1281
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1281
-4
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ packages/svelte2tsx/test/emitDts/samples/*/expected/**
66
packages/language-server/test/**/*.svelte
77
packages/language-server/test/**/testfiles/**/*.ts
88
packages/svelte-vscode/syntaxes/*.yaml
9+
packages/svelte-vscode/test/*/samples/**/*
910
packages/typescript-plugin/src/**/*.js
1011
packages/typescript-plugin/src/**/*.d.ts
1112
**/dist

packages/svelte-vscode/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"build": "npm run build:ts && npm run build:grammar",
1010
"vscode:prepublish": "npm run build && npm prune --production",
1111
"watch": "npm run build:grammar && tsc -w -p ./",
12-
"test": "echo 'NOOP'"
12+
"test": "npm run build:grammar && node test/grammar/test.js"
1313
},
1414
"repository": {
1515
"type": "git",
@@ -568,7 +568,8 @@
568568
"@types/node": "^13.9.0",
569569
"@types/vscode": "*",
570570
"js-yaml": "^3.14.0",
571-
"typescript": "*"
571+
"typescript": "*",
572+
"vscode-tmgrammar-test": "^0.0.11"
572573
},
573574
"dependencies": {
574575
"lodash": "^4.17.21",

packages/svelte-vscode/syntaxes/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,19 @@ A good document to read in more detail about TextMate: https://www.apeth.com/non
99
## Developing the grammar
1010

1111
The grammar for pug and markdown is written in JSON. You can edit that directly. The main grammar is written in `yaml` because that's easier to structure than JSON. However, VS Code expects a JSON format. Therefore you need to run the `build:grammar` script afterwards. This will produce a JSON version of the file. Afterwards you need to restart your extension window for the changes to take effect.
12+
13+
### Snapshot test for the grammar
14+
15+
The snapshot test is run by [vscode-textmate-test](https://github.com/PanAeon/vscode-tmgrammar-test). The `test` command called a node script to build the argument and execute the `vscode-textmate-test` command. If you updated the svelte grammar file, Be sure to add the test cases to the `test/sample` directory.
16+
17+
Then run the test to check if the update affect existing cases
18+
19+
```bash
20+
yarn test
21+
```
22+
23+
Update existing snapshot to match the changes
24+
25+
```bash
26+
yarn test --updateSnapshot
27+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"comment": "Dummy CoffeeScript TextMate grammar for use in testing",
3+
"scopeName": "source.coffee"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"comment": "Dummy CSS TextMate grammar for use in testing",
3+
"scopeName": "source.css"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"comment": "Dummy HTML TextMate grammar for use in testing",
3+
"scopeName": "text.html"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"comment": "Dummy JS TextMate grammar for use in testing",
3+
"scopeName": "source.js"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"comment": "Dummy Less TextMate grammar for use in testing",
3+
"scopeName": "source.css.less"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"comment": "Dummy Pug TextMate grammar for use in testing",
3+
"scopeName": "text.pug"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"comment": "Dummy Sass TextMate grammar for use in testing",
3+
"scopeName": "source.sass"
4+
}

0 commit comments

Comments
 (0)