Skip to content

Commit ca7196a

Browse files
authored
Allow loading config files in TypeScript format (#2709)
1 parent ca673bf commit ca7196a

File tree

5 files changed

+189
-68
lines changed

5 files changed

+189
-68
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) on how to contribute to Cucumber.
99

1010
## [Unreleased]
11+
### Added
12+
- Allow loading config files in TypeScript format ([#2709](https://github.com/cucumber/cucumber-js/pull/2709))
13+
1114
### Changed
1215
- Compress report content with gzip before publishing ([#2687](https://github.com/cucumber/cucumber-js/pull/2687))
1316

docs/configuration.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,18 @@ module.exports = {
7171

7272
(If you're wondering why the configuration sits within a "default" property, that's to allow for [Profiles](./profiles.md).)
7373

74-
### Type checking
74+
### TypeScript
7575

76-
If you want to type check your configuration, we export two types that can help with that:
77-
- `IProfiles` represents the dictionary of profile names to configuration objects exported for CommonJS
78-
- `IConfiguration` represents a single configuration object exported with named exports for ESM (`Partial<IConfiguration>` will be more useful in practise)
76+
You can also write your configuration file in TypeScript, with a `.ts`, `.mts` or `.cts` extension. These files are loaded with [Node.js built-in TypeScript support](https://nodejs.org/api/typescript.html), which has several caveats and limitations, mostly that your `tsconfig.json` won't be honoured and that you need to be explicit about type imports. Here's an example:
77+
78+
```typescript
79+
import type { IConfiguration } from '@cucumber/cucumber'
80+
81+
export default {
82+
parallel: 2,
83+
format: ['html:cucumber-report.html']
84+
} satisfies Partial<IConfiguration>
85+
```
7986

8087
## Options
8188

package-lock.json

Lines changed: 35 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)