Skip to content

Commit ca3ac61

Browse files
author
DavertMik
committed
fixed faker tests
1 parent 92b70d2 commit ca3ac61

File tree

2 files changed

+54
-5
lines changed

2 files changed

+54
-5
lines changed

lib/plugin/fakerTransform.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { faker } from '@faker-js/faker';
2+
import transform from '../transform.js';
3+
4+
/**
5+
* Use the `@faker-js/faker` package to generate fake data inside examples on your gherkin tests
6+
*
7+
* #### Usage
8+
*
9+
* To start please install `@faker-js/faker` package
10+
*
11+
* ```
12+
* npm install -D @faker-js/faker
13+
* ```
14+
*
15+
* ```
16+
* yarn add -D @faker-js/faker
17+
* ```
18+
*
19+
* Add this plugin to config file:
20+
*
21+
* ```js
22+
* plugins: {
23+
* fakerTransform: {
24+
* enabled: true
25+
* }
26+
* }
27+
* ```
28+
*
29+
* Add the faker API using a mustache string format inside examples tables in your gherkin scenario outline
30+
*
31+
* ```feature
32+
* Scenario Outline: ...
33+
* Given ...
34+
* When ...
35+
* Then ...
36+
* Examples:
37+
* | productName | customer | email | anythingMore |
38+
* | {{commerce.product}} | Dr. {{name.findName}} | {{internet.email}} | staticData |
39+
* ```
40+
*
41+
*/
42+
export default function (config) {
43+
transform.addTransformerBeforeAll('gherkin.examples', value => {
44+
if (typeof value === 'string' && value.length > 0) {
45+
return faker.helpers.fake(value);
46+
}
47+
return value;
48+
});
49+
}

test/support/ScreenshotSessionHelper.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import Helper from '@codeceptjs/helper'
2-
import crypto from 'crypto'
3-
import fs from 'fs'
1+
import Helper from 'codeceptjs/lib/helper.js';
2+
import crypto from 'crypto';
3+
import fs from 'fs';
44

55
class ScreenshotSessionHelper extends Helper {
66
constructor(config) {
7-
super(config)
8-
this.outputPath = global.output_dir
7+
super(config);
8+
this.outputPath = global.output_dir;
99
}
1010

1111
getSHA256Digests(files = []) {

0 commit comments

Comments
 (0)