-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into skipped-typings
- Loading branch information
Showing
32 changed files
with
402 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,37 @@ | ||
# Frequently Asked Questions | ||
|
||
#### The world instance isn’t available in my hooks or step definitions. | ||
## The world instance isn’t available in my hooks or step definitions. | ||
|
||
This has frequently been caused by the use of ES6 arrow functions. | ||
If you are using the world instance (which is bound to `this`) in a step definition, then you cannot use ES6 arrow functions for step definitions or hooks because they bind `this` to the current context which prevents the world instance from being injected. | ||
|
||
#### Why do my definition patterns need to be globally unique instead of unique only within `Given`, `When`, `Then`? | ||
## Why do my definition patterns need to be globally unique instead of unique only within `Given`, `When`, `Then`? | ||
|
||
To encourage a ubiquitous, non-ambiguous domain language. | ||
Using the same language to mean different things is basically the definition of ambiguous. | ||
If you have similar `Given` and `Then` patterns, try adding the word “should” to `Then` patterns. | ||
|
||
## Why am I seeing `The "from" argument must be of type string. Received type undefined`? | ||
|
||
If when running cucumber-js you see an error with a stack trace like: | ||
|
||
``` | ||
TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received type undefined | ||
at validateString (internal/validators.js:125:11) | ||
at Object.relative (path.js:1162:5) | ||
... | ||
``` | ||
|
||
This usually an effect of one of: | ||
|
||
- Your project depends on cucumber-js, and also has a dependency (in `node_modules`) that depends on cucumber-js at a different version | ||
- You have a package that depends (even as a dev dependency) on cucumber-js linked (via `npm link` or `yarn link`) | ||
|
||
These cases can cause two different instances of cucumber-js to be in play at runtime, which causes errors. | ||
|
||
If removing the duplicate dependency is not possible, you can work around this by using [import-cwd](https://www.npmjs.com/package/import-cwd) so your support code always requires cucumber-js from the current working directory (i.e. your host project): | ||
|
||
```js | ||
const importCwd = require('import-cwd') | ||
const { Given, When, Then } = importCwd('@cucumber/cucumber') | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Migrating to cucumber-js 7.x.x | ||
|
||
## Package Name | ||
|
||
cucumber-js is now published at `@cucumber/cucumber` instead of `cucumber`. To upgrade, you'll need to remove the old package and add the new one: | ||
|
||
```shell | ||
$ npm rm cucumber | ||
$ npm install --save-dev @cucumber/cucumber | ||
``` | ||
|
||
You'll need to update any `import`/`require` statements in your support code to use the new package name. | ||
|
||
(The executable is still `cucumber-js` though.) | ||
|
||
## Formatters | ||
|
||
The underlying event/data model for cucumber-js is now [cucumber-messages](https://github.com/cucumber/cucumber/tree/master/messages), a shared standard across all official Cucumber implementations. This replaces the old "event protocol". | ||
|
||
If you maintain any custom formatters, you'll need to refactor them to work with the new model. The basics of a `Formatter` class are the same, and the `EventDataCollector` is still there to help you with tracking down data, but the names of events and shape of their data is different. It's worth checking out the implementations of the built-in formatters if you need a pointer. | ||
|
||
We now support referring to custom formatters on the path by module/package name, for example: | ||
|
||
```shell | ||
$ cucumber-js --format @cucumber/pretty-formatter | ||
``` | ||
|
||
This does mean that if you want to point to a local formatter implementation (i.e. not a Node module) then you should ensure it's a relative path starting with `./`. | ||
|
||
## Parallel | ||
|
||
The parallel mode previously used problematic "master"/"slave" naming that we've dropped in favour of "coordinator" and "worker". This is mostly an internal detail, but is also reflected in the names of some environment variables you might be using: | ||
|
||
* `CUCUMBER_TOTAL_SLAVES` is now `CUCUMBER_TOTAL_WORKERS` | ||
* `CUCUMBER_SLAVE_ID` is now `CUCUMBER_WORKER_ID` | ||
|
||
## TypeScript | ||
|
||
*(You can skip this part if you don't use TypeScript in your projects.)* | ||
|
||
Where before we relied on the community-authored `@types/cucumber` package, cucumber-js is now built with TypeScript and as such includes its own typings, so you can drop your dependency on the separate package: | ||
|
||
```shell | ||
$ npm rm @types/cucumber | ||
``` | ||
|
||
There are a few minor differences to be aware of: | ||
|
||
- The type for data tables was named `TableDefinition` - it's now named `DataTable` | ||
- `World` was typed as an interface, but it's actually a class - you should `extend` it when [building a custom formatter](./custom_formatters.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.