Thank you for contributing! Please follow these steps before preparing a pull request
You need docker installed. This is because the build process uses docker to build wasm files.
npm install
npm test
If you need to test your changes in an editor, use VSCode. See cucumber/vscode/CONTRIBUTING.md for details.
If your contribution is to add support for a new programming language, follow these steps:
- Read and understand tree-sitter. Its job is to query the source code of whatever language you are trying to add support for. By doing this we can find the specific functions or methods that correspond to that language's Cucumber support. This allows the
language-service
to abstract away the language specific components and allows the rest of the program to work in more universal Gherkin space. - Run
npm install -E tree-sitter-{language}
- Update
languages
inscripts/build.js
and add it to cucumber/vscode/README.md. - Run
npm install
- this should build a wasm for the new language intodist/{language}.wasm
- Add
test/language/testdata/{language}/StepDefinitions.{ext}
, porting the names and expressions from one of the existing implementations. - If the Cucumber implementation supports Cucumber Expressions, add
test/language/testdata/{language}/ParameterTypes.{ext}
. - Add a new
src/language/{language}Language.ts
file- If the Cucumber implementation does not support Cucumber Expressions, make
defineParameterTypeQueries
an empty array
- If the Cucumber implementation does not support Cucumber Expressions, make
- Add the name of the new language to the
LanguageNames
type - Update
languageByName
insrc/language/language.ts
- Add a new
case
statement insrc/tree-sitter-node/NodeParserAdapter.ts
- Update
cucumberExpressionsSupport
intest/language/ExpressionBuilder.test.ts
to include the new language if it supports Cucumber Expressions - Run tests
As you are working on step 5-7 - use tree-sitter playground to build your query. The queries must have capturing nodes:
defineParameterTypeQueries
:@expression
,@name
and@root
defineStepDefinitionQueries
:@expression
and@root
Changing the names of these aliases will result in test failures, even if they work within the tree-sitter playground.
Languages should contain a snippet in their respective src/language/{language}Language.ts
.
Below is the canonical Ruby example:
{{ keyword }}('{{ expression }}') do |{{ #parameters }}{{ #seenParameter }}, {{ /seenParameter }}{{ name }}{{ /parameters }}|
// {{ blurb }}
end
This is a Mustache Template. Here is the documentation
Here there are a number of properties to use:
keyword
isGiven
,When
orThen
.expression
is the suggested Cucumber Expression for the undefined step.blurb
is the comment you should put inside the step definition body.parameters
is an array of parameters to use in the function/method/block signature. Each item has three properties:name
is the name of the parameter.type
is the type of the parameter (for statically typed languages).seenParameter
is a boolean which isfalse
for the first parameter andtrue
for the following ones. Useful for adding a,
.
Please make sure all code is formatted before submitting a pull request
npm run eslint-fix