-
Notifications
You must be signed in to change notification settings - Fork 73
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
generator-langium: extended yeoman generator extension to offer parsing, linking, and validation test stubs (#1282) #1298
Conversation
8539202
to
cbf46c3
Compare
@sailingKieler
Could it be that there are too many Dir name in my case is: |
Hi Dennis,
The test is supposed to write |
@sailingKieler |
@dhuebner you're right, and I guess that's due to the introduction of
|
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! This is a good addition that has been missing so far.
`); | ||
|
||
// check for absensce of parser errors the classic way: | ||
// deacivated, find a much more human readable way below! |
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.
Note: "more human readable" is true for the test output in case of failure, but the readability of the test code is worse. In that regard, I prefer the straightforward one-liner.
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.
I propose to keep the code as it it, but add more explanation why it's useful to optimize for test output readability.
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.
It's basically everybody's choice to switch back to the one liner version.
Regrettably there's no way of attaching custom messages in case of failures AFAIK.
I think it's a chance to show users alternatives. 😉
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.
Added some explanation:
langium/packages/generator-langium/templates/test/test/parsing/parsing.test.ts
Lines 28 to 37 in 01c9028
// check for absensce of parser errors the classic way: | |
// deacivated, find a much more human readable way below! | |
// expect(document.parseResult.parserErrors).toHaveLength(0); | |
expect( | |
// here we use a (tagged) template expression to create a human readable representation | |
// of the AST part we are interested in and that is to be compared to our expectation; | |
// prior to the tagged template expression we check for validity of the parsed document object | |
// by means of the reusable function 'checkDocumentValid()' to sort out (critical) typos first; | |
checkDocumentValid(document) || s` |
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.
Regrettably there's no way of attaching custom messages in case of failures AFAIK.
There is, just use expect(value, failureMessage)...
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.
😱 Since when is that?
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.
Since we switched to vitest :)
eda512f
to
01c9028
Compare
@dhuebner feel free to give another try |
packages/generator-langium/templates/test/test/linking/linking.test.ts
Outdated
Show resolved
Hide resolved
packages/generator-langium/templates/test/test/validating/validating.test.ts
Show resolved
Hide resolved
e12ba9c
to
7b0a010
Compare
okay I dropped the options, and the Jest support, apparently I'm the only lonely wolf using it (in a commercial project). Should it then be a question, at all? Maybe not. |
6174214
to
af91751
Compare
af91751
to
aadafcc
Compare
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, it looks really good. Just two issues:
- I see this in the editor for tsconfig.json:
File '/workspace/langium/examples/hello-world/test/linking/linking.test.ts' is not under 'rootDir' '/workspace/langium/examples/hello-world/src'. 'rootDir' is expected to contain all source files.
The file is in the program because:
Matched by include pattern 'test/**/*.ts' in '/workspace/langium/examples/hello-world/tsconfig.json'
File is ECMAScript module because '/workspace/langium/examples/hello-world/package.json' has field "type" with value "module"
- I get the following error when I answer "Yes" to all questions:
"initialize" is not exported by "../../node_modules/vscode/extensions.js", imported by "../../node_modules/monaco-languageclient/lib/monaco-vscode-api-services.js".
file: /workspace/langium/node_modules/monaco-languageclient/lib/monaco-vscode-api-services.js:6:9
4: * ------------------------------------------------------------------------------------------ */
5: import { ILogService, initialize, StandaloneServices } from 'vscode/services';
6: import { initialize as initializeVscodeExtensions } from 'vscode/extensions';
^
7: import getLanguagesServiceOverride from '@codingame/monaco-vscode-languages-service-override';
8: import getModelServiceOverride from '@codingame/monaco-vscode-model-service-override';
error during build:
RollupError: "initialize" is not exported by "../../node_modules/vscode/extensions.js", imported by "../../node_modules/monaco-languageclient/lib/monaco-vscode-api-services.js".
@spoenemann the second problem I will fix with a separate PR. The minor updates of |
⬆️ Fix is here: #1317 @sailingKieler consider upgrading to vite v5 / vitest v1 before merging this PR. |
Wouldn't that be out of scope for this PR? |
Only for the generated output, not the whole project |
Of course 🤦🏽♂️ 😅 |
aadafcc
to
89e458a
Compare
89e458a
to
589aef4
Compare
Tested upgrading to The latter causes a conflict during
Do you wanna switch to v18 as minimally required node.js version? |
589aef4
to
b03513b
Compare
The question is why not. node 18 was the last LTS version. 20 is the current LTS version. 16 is outdated. |
Filed dedicated PR #1319 |
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, looks good!
ea60a27
to
21e16c4
Compare
@msujew @kaisalmen I upgraded the versions of node.js & vitest in the generated Can you guys have a final look? |
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.
Looks good to me. Just minor typos, see below 👍
packages/generator-langium/templates/test/test/validating/validating.test.ts
Outdated
Show resolved
Hide resolved
packages/generator-langium/templates/test/test/parsing/parsing.test.ts
Outdated
Show resolved
Hide resolved
packages/generator-langium/templates/test/test/linking/linking.test.ts
Outdated
Show resolved
Hide resolved
…ng, linking, and validation test stubs (#1282) * providing an additional automated test running 'npm test' and checking its proper termination
21e16c4
to
4f28473
Compare
the cases of 'stubsOnly','vitest', and 'jest'