Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Node.js Package
name: Publish Package

on:
release:
types: [created]
types: [published]

permissions:
id-token: write
contents: read

jobs:
publish-npm:
Expand All @@ -18,6 +19,4 @@ jobs:
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run build
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
- run: npm publish --access public
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

:microscope: - experimental

## [1.7.0]
- :rocket: added `filter` grep utility function
```typescript
import { filter } from '@qavajs/playwright-runner-adapter';
export default defineConfig({
grep: filter(name => name.includes('login test'))
});
```
- :rocket: expose `uri` test annotation

## [1.6.0]
- :rocket: added `Template` utility function
```typescript
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,23 @@ class ExtendedPlaywrightWorld extends PlaywrightWorld {
}
```

### Tag expression
### Tag expression and filter
It is possible to use regular tag expressions via `tags` util function

```typescript
import { tags } from '@qavajs/playwright-runner-adapter';
export default defineConfig({
grep: tags('@oneTag and @anotherTag')
})
});
```

or filter tests by predicate

```typescript
import { filter } from '@qavajs/playwright-runner-adapter';
export default defineConfig({
grep: filter(name => name.includes('login test'))
});
```

## Limitation
Expand Down
68 changes: 37 additions & 31 deletions package-lock.json

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

37 changes: 31 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@qavajs/playwright-runner-adapter",
"version": "1.6.0",
"version": "1.7.0",
"description": "adapter for playwright test runner",
"main": "adapter/index.js",
"types": "adapter/index.d.ts",
Expand All @@ -19,14 +19,39 @@
"url": "https://github.com/qavajs/playwright-runner-adapter/issues"
},
"dependencies": {
"@cucumber/gherkin": "^35.1.0",
"@cucumber/tag-expressions": "^6.2.0",
"@cucumber/gherkin": "^36.0.0",
"@cucumber/tag-expressions": "^8.0.0",
"glob": "^11.0.3",
"@cucumber/cucumber": "^12.2.0"
},
"devDependencies": {
"@playwright/test": "^1.55.1",
"@types/node": "^24.6.2",
"@playwright/test": "^1.56.1",
"@types/node": "^24.9.1",
"typescript": "^5.9.3"
}
},
"keywords": [
"test",
"automation",
"testing",
"qa",
"quality-assurance",
"test-framework",
"test-runner",
"test-automation",
"e2e",
"end-to-end",
"ui-testing",
"integration-testing",
"acceptance-testing",
"functional-testing",
"browser-testing",
"mobile-testing",
"cross-browser",
"bdd",
"gherkin",
"assertions",
"continuous-delivery",
"automation-framework",
"playwright"
]
}
3 changes: 2 additions & 1 deletion src/cucumber.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ for (const feature of features) {
const tag = [...new Set(testCase.tags.map((tag: { name: string }) => tag.name))];
const annotation = [
{ type: 'name', description: testCase.name },
{ type: 'uri', description: testCase.uri },
{ type: 'testId', description: testCase.id },
{ type: 'tags', description: JSON.stringify(tag) }
];
test(testCase.name, { tag, annotation: annotation }, async () => {
test(testCase.name, { tag, annotation }, async () => {
const testInfo = test.info();
testInfo.result = { status: 'passed' };
for (const pickleStep of testCase.steps) {
Expand Down
27 changes: 25 additions & 2 deletions src/tags.ts → src/filter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import parse from '@cucumber/tag-expressions'
import parse from '@cucumber/tag-expressions';

class TagExpression extends RegExp {
private expressionNode: {
Expand All @@ -23,8 +23,31 @@ class TagExpression extends RegExp {
* import { tags } from '@qavajs/playwright-runner-adapter';
* export default defineConfig({
* grep: tags('@oneTag and @anotherTag')
* })
* });
*/
export function tags(tagExpression: string): RegExp {
return new TagExpression(tagExpression);
}

class Filter extends RegExp {
constructor(private predicate: (testName: string) => boolean) {
super('');
this.predicate = predicate;
}

test(testName: string) {
return this.predicate(testName);
}
}

/**
* Filter test cases by name
* @param {(testName: string) => boolean} predicate
* import { filter } from '@qavajs/playwright-runner-adapter';
* export default defineConfig({
* grep: filter(name => name.includes('login test'))
* });
*/
export function filter(predicate: (testName: string) => boolean): RegExp {
return new Filter(predicate);
}
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './PlaywrightWorld';
export * from './defineCucumber';
export * from './tags';
export * from './filter';
export * from './Template';
export * from '@cucumber/cucumber';
3 changes: 1 addition & 2 deletions test/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { defineConfig, devices } from '@playwright/test';
import { defineCucumber } from '../src/defineCucumber';
import { tags } from '../src/tags';
import { defineCucumber, tags } from '../src';

/**
* See https://playwright.dev/docs/test-configuration.
Expand Down