Skip to content

Commit

Permalink
Merge pull request #84 from ronvoluted/docs/fix-typos
Browse files Browse the repository at this point in the history
Fix errors in docs
  • Loading branch information
vitalets authored Jan 10, 2024
2 parents a82d343 + e8c214a commit a80355c
Show file tree
Hide file tree
Showing 19 changed files with 64 additions and 30 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ jobs:
playwrightVersion: ${{ fromJson(needs.get-playwright-versions.outputs.versions) }}
cucumberVersion: ['9']
include:
# there were breaking changes in cucumber 10.1 -> test on both 10.0 and 10
# there were breaking changes in cucumber 10.x -> test on 10.0 and 10.1
- playwrightVersion: '1.37'
cucumberVersion: '10.0'
- playwrightVersion: '1.38'
cucumberVersion: '10.1'
- playwrightVersion: '1.39'
cucumberVersion: '10'
steps:
- uses: actions/checkout@v3
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Changelog

## 5.7.1
* support Cucumber 10.2

## 5.7.0
* suppport Cucumber 10.1, [#80](https://github.com/vitalets/playwright-bdd/issues/80)
* support Cucumber 10.1, [#80](https://github.com/vitalets/playwright-bdd/issues/80)

## 5.6.0
* support component tests, [#57](https://github.com/vitalets/playwright-bdd/issues/57)
Expand Down
4 changes: 2 additions & 2 deletions docs/ide-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Playwright-bdd provides support for all Playwright IDE integrations, because gen
* [Cucumber autocomplete extension](https://marketplace.visualstudio.com/items?itemName=alexkrechik.cucumberautocomplete) works as usual:
<img width="70%" src="https://user-images.githubusercontent.com/1473072/229165348-eae41fb8-0918-48ac-8644-c55a880860de.png">

## Intellij Idea / Aqua
## IntelliJ IDE / Aqua
Built-in Playwright support works as usual:
<img width="70%" src="https://github.com/vitalets/playwright-bdd/assets/1473072/bf82dfdc-9797-44d0-b07c-185aea578174">

> You may need to set path to Playwright executable in [Run Configuration Template](https://www.jetbrains.com/help/idea/run-debug-configuration.html#change-template) to avoid popup window before every test run
> You may need to set path to Playwright executable in [Run Configuration Template](https://www.jetbrains.com/help/idea/run-debug-configuration.html#change-template) to avoid popup window before every test run
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test.describe('Playwright site', () => {
```

### Phase 2: Run tests
CLI commmand `npx playwright test` runs generated test files with Playwright runner.
CLI command `npx playwright test` runs generated test files with Playwright runner.
Playwright-bdd makes Playwright API available in step definitions (`page`, `browser`, etc):

```js
Expand All @@ -73,4 +73,4 @@ Then('I see in title {string}', async ({ page }, text) => {
});
```

Proceed to [installation guide](installation.md) to try it in action!
Proceed to [installation guide](installation.md) to try it in action!
4 changes: 2 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ npm i -D playwright-bdd

This package uses `@playwright/test` and `@cucumber/cucumber` as a peer dependencies.
For brand new projects they will be installed automatically with `playwright-bdd`.
For existing projects you may need to update them to the latest verions:
For existing projects you may need to update them to the latest versions:

```
npm i -D @playwright/test @cucumber/cucumber
Expand All @@ -18,4 +18,4 @@ After installing/updating Playwright you need to [install browsers](https://play

```
npx playwright install
```
```
4 changes: 2 additions & 2 deletions docs/writing-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ It can be not reliable for reporters that keep track of test history, because on
There are 3 ways to set consistent title for examples.

#### 1. Use scenario name as a template
You can add column names like `<column>` to the scenario name. In that case sceanrio name will be used as a title template for generated examples. E.g.:
You can add column names like `<column>` to the scenario name. In that case scenario name will be used as a title template for generated examples. E.g.:
```gherkin
Feature: Localization
Expand Down Expand Up @@ -194,7 +194,7 @@ Strictly use only the following step definitions:
{steps list from bddgen export}
```
> Feel free to imporve that template and share the results
> Feel free to improve that template and share the results
Filled prompt for Todo app:
```
Expand Down
4 changes: 2 additions & 2 deletions docs/writing-steps.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ There are two ways of writing step definitions:
2. **Cucumber-style** - recommended for migrating existing CucumberJS projects to Playwright runner

## Playwright-style
Playwright-style allows you to write step definitions like a regular playwright tests.
Playwright-style allows you to write step definitions like regular Playwright tests.
You get all benefits of [built-in fixtures](https://playwright.dev/docs/test-fixtures#built-in-fixtures) as well as [custom fixtures](https://playwright.dev/docs/test-fixtures#with-fixtures).

Playwright-style highlights:
Expand Down Expand Up @@ -306,7 +306,7 @@ When('I open todo page', async function () {
```

For **TypeScript** you can pass `typeof test` as a second generic parameter to `BddWorld`
to get propper typing:
to get proper typing:

```ts
type MyWorld = BddWorld<object, typeof test>;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "playwright-bdd",
"description": "BDD Testing with Playwright runner and CucumberJS",
"version": "5.7.0",
"version": "5.7.1",
"type": "commonjs",
"bin": {
"bddgen": "./dist/cli/index.js"
Expand Down
2 changes: 1 addition & 1 deletion src/cucumber/buildStepDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IdGenerator } from '@cucumber/messages';
import { CucumberExpression, RegularExpression } from '@cucumber/cucumber-expressions';
import { GherkinStepKeyword } from '@cucumber/cucumber/lib/models/gherkin_step_keyword';
import StepDefinition from '@cucumber/cucumber/lib/models/step_definition';
import { ISupportCodeLibrary } from '@cucumber/cucumber/api';
import { ISupportCodeLibrary } from './types';

/* eslint-disable @typescript-eslint/no-explicit-any */

Expand Down
4 changes: 3 additions & 1 deletion src/cucumber/loadSnippetBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { FormatterBuilder } from '@cucumber/cucumber';
import { ISupportCodeLibrary } from '@cucumber/cucumber/api';
import { SnippetInterface } from '@cucumber/cucumber/lib/formatter/step_definition_snippet_builder/snippet_syntax';
import { ISupportCodeLibrary } from './types';

export async function loadSnippetBuilder(
supportCodeLibrary: ISupportCodeLibrary,
Expand All @@ -16,6 +16,8 @@ export async function loadSnippetBuilder(
cwd: process.cwd(),
snippetInterface,
snippetSyntax,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore it's safe to use our ISupportCodeLibrary because only .parameterTypeRegistry is used
supportCodeLibrary,
});
}
6 changes: 4 additions & 2 deletions src/cucumber/loadSteps.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IRunConfiguration, IRunEnvironment, loadSupport } from '@cucumber/cucumber/api';
import { ISupportCodeLibrary } from '@cucumber/cucumber/lib/support_code_library_builder/types';
import { installTransform } from '../playwright/transform';
import { exit } from '../utils/exit';
import { ISupportCodeLibrary } from './types';

const cache = new Map<string, Promise<ISupportCodeLibrary>>();

Expand All @@ -16,7 +16,9 @@ export async function loadSteps(
// use Playwright's built-in hook to compile TypeScript steps
// eslint-disable-next-line @typescript-eslint/no-empty-function
const uninstall = !hasTsNodeRegister(runConfiguration) ? installTransform() : () => {};
lib = loadSupport(runConfiguration, environment).finally(() => uninstall());
lib = loadSupport(runConfiguration, environment).finally(() =>
uninstall(),
) as Promise<ISupportCodeLibrary>;
cache.set(cacheKey, lib);
}

Expand Down
22 changes: 22 additions & 0 deletions src/cucumber/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Cucumber types.
* Use types from here to be independent from changes in Cucumber.
*
* See: https://github.com/cucumber/cucumber-js/blob/main/src/support_code_library_builder/types.ts#L153
*/
import type { ParameterTypeRegistry } from '@cucumber/cucumber-expressions';
import type StepDefinition from '@cucumber/cucumber/lib/models/step_definition';

export interface ISupportCodeLibrary {
parameterTypeRegistry: ParameterTypeRegistry;
stepDefinitions: StepDefinition[];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
World: any;
originalCoordinates: ISupportCodeCoordinates;
}

interface ISupportCodeCoordinates {
requireModules: string[];
requirePaths: string[];
importPaths: string[];
}
2 changes: 1 addition & 1 deletion src/gen/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { TestFile } from './testFile';
import { loadConfig as loadCucumberConfig } from '../cucumber/loadConfig';
import { loadFeatures } from '../cucumber/loadFeatures';
import { hasTsNodeRegister, loadSteps } from '../cucumber/loadSteps';
import { ISupportCodeLibrary } from '@cucumber/cucumber/lib/support_code_library_builder/types';
import { extractCucumberConfig, BDDConfig } from '../config';
import { Snippets } from '../snippets';
import { IRunConfiguration } from '@cucumber/cucumber/api';
Expand All @@ -20,6 +19,7 @@ import { Logger } from '../utils/logger';
import parseTagsExpression from '@cucumber/tag-expressions';
import { exit, withExitHandler } from '../utils/exit';
import { hasCustomTest } from '../stepDefinitions/createBdd';
import { ISupportCodeLibrary } from '../cucumber/types';

/* eslint-disable @typescript-eslint/no-non-null-assertion */

Expand Down
2 changes: 1 addition & 1 deletion src/gen/testFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import fs from 'node:fs';
import path from 'node:path';
import { Formatter } from './formatter';
import { KeywordsMap, getKeywordsMap } from './i18n';
import { ISupportCodeLibrary } from '@cucumber/cucumber/lib/support_code_library_builder/types';
import { findStepDefinition } from '../cucumber/loadSteps';
import { BDDConfig } from '../config';
import { KeywordType, getStepKeywordType } from '@cucumber/cucumber/lib/formatter/helpers/index';
Expand All @@ -38,6 +37,7 @@ import StepDefinition from '@cucumber/cucumber/lib/models/step_definition';
import { hasScenarioHooks, getScenarioHooksFixtures } from '../hooks/scenario';
import { getWorkerHooksFixtures } from '../hooks/worker';
import { LANG_EN, isEnglish } from '../config/lang';
import { ISupportCodeLibrary } from '../cucumber/types';

type TestFileOptions = {
doc: GherkinDocument;
Expand Down
3 changes: 2 additions & 1 deletion src/run/bddFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import { appendDecoratorSteps } from '../stepDefinitions/decorators/steps';
import { getPlaywrightConfigDir } from '../config/dir';
import { runScenarioHooks } from '../hooks/scenario';
import { runWorkerHooks } from '../hooks/worker';
import { IRunConfiguration, ISupportCodeLibrary } from '@cucumber/cucumber/api';
import { IRunConfiguration } from '@cucumber/cucumber/api';
import { StepInvoker } from './StepInvoker';
import { ISupportCodeLibrary } from '../cucumber/types';

// BDD fixtures prefixed with '$' to avoid collision with user's fixtures.

Expand Down
2 changes: 1 addition & 1 deletion src/run/bddWorld.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { APIRequestContext, Browser, BrowserContext, Page, TestInfo } from '@playwright/test';
import { World as CucumberWorld, IWorldOptions } from '@cucumber/cucumber';
import { ISupportCodeLibrary } from '@cucumber/cucumber/lib/support_code_library_builder/types';
import { Fixtures, TestTypeCommon } from '../playwright/types';
import { ISupportCodeLibrary } from '../cucumber/types';

export type BddWorldFixtures = {
page: Page;
Expand Down
10 changes: 7 additions & 3 deletions src/snippets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
*/

import { pathToFileURL } from 'node:url';
import { IRunConfiguration, ISupportCodeLibrary } from '@cucumber/cucumber/api';
import { IRunConfiguration } from '@cucumber/cucumber/api';
import { loadSnippetBuilder } from '../cucumber/loadSnippetBuilder';
import { TestFile, UndefinedStep } from '../gen/testFile';
import StepDefinitionSnippetBuilder from '@cucumber/cucumber/lib/formatter/step_definition_snippet_builder';
import { SnippetInterface } from '@cucumber/cucumber/lib/formatter/step_definition_snippet_builder/snippet_syntax';
import { logger } from '../utils/logger';
import { getStepConfig, isDecorator, isPlaywrightStyle } from '../stepDefinitions/stepConfig';
import { ISupportCodeLibrary } from '../cucumber/types';

export class Snippets {
private snippetBuilder!: StepDefinitionSnippetBuilder;
Expand All @@ -30,13 +32,15 @@ export class Snippets {
}

private async createSnippetBuilder() {
const { snippetInterface } = this.runConfiguration.formats.options;
const snippetInterface = this.runConfiguration.formats.options.snippetInterface as
| SnippetInterface
| undefined;
const snippetSyntax = this.getSnippetSyntax();
return loadSnippetBuilder(this.supportCodeLibrary, snippetInterface, snippetSyntax);
}

private getSnippetSyntax() {
const { snippetSyntax } = this.runConfiguration.formats.options;
const snippetSyntax = this.runConfiguration.formats.options.snippetSyntax as string | undefined;
if (!snippetSyntax && this.isPlaywrightStyle()) {
this.bddBuiltInSyntax = true;
const filePath = this.isDecorators()
Expand Down
6 changes: 2 additions & 4 deletions src/stepDefinitions/decorators/steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
/* eslint-disable @typescript-eslint/ban-types */

import { isBddAutoInjectFixture } from '../../run/bddFixtures';
import {
DefineStepPattern,
ISupportCodeLibrary,
} from '@cucumber/cucumber/lib/support_code_library_builder/types';
import { DefineStepPattern } from '@cucumber/cucumber/lib/support_code_library_builder/types';
import { buildStepDefinition } from '../../cucumber/buildStepDefinition';
import { GherkinStepKeyword } from '@cucumber/cucumber/lib/models/gherkin_step_keyword';
import { StepConfig } from '../stepConfig';
import { buildCucumberStepCode } from '../defineStep';
import { PomNode } from './class';
import { ISupportCodeLibrary } from '../../cucumber/types';

// initially we sotre step data inside method,
// and then extract it in @Fixture decorator call
Expand Down

0 comments on commit a80355c

Please sign in to comment.