Skip to content

Commit 2483771

Browse files
committed
feat: add getCodeReport function
feat: add Gherkin step functions
1 parent 1da8367 commit 2483771

18 files changed

Lines changed: 231 additions & 41 deletions
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import type {testIdentifierKey} from 'autotests/configurator';
2+
13
/**
24
* Test metadata parameters (testId, severity, etc).
35
*/
46
export type TestMeta = Readonly<{
5-
testId: string;
7+
[testIdentifierKey]: string;
68
}>;

‎autotests/projectSettings.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"allFeatureFileGlobs": [],
23
"allTestFileGlobs": ["**/autotests/tests/**/*.ts"],
34
"dockerImage": "e2edhub/e2ed",
45
"pathToTsConfigFromRoot": "./tsconfig.json",

‎src/README.md‎

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Dependency graph
22

3-
This is a graph of the base modules of the project with dependencies between them.
3+
This is a graph of the base modules of the project with dependencies between them
4+
(for runtime values only, not for types).
45

56
Modules in the dependency graph should only import the modules above them:
67

@@ -27,33 +28,36 @@ Modules in the dependency graph should only import the modules above them:
2728
20. `utils/uiMode`
2829
21. `utils/runLabel`
2930
22. `utils/clone`
30-
23. `utils/notIncludedInPackTests`
31-
24. `utils/userland`
32-
25. `utils/fn`
33-
26. `utils/environment`
34-
27. `utils/packCompiler`
35-
28. `config`
36-
29. `utils/config`
37-
30. `utils/generalLog`
38-
31. `utils/testFilePaths`
39-
32. `utils/exit`
40-
33. `utils/promise`
41-
34. `utils/resourceUsage`
42-
35. `utils/fs`
43-
36. `utils/completedTestRuns`
44-
37. `utils/getGlobalErrorHandler`
45-
38. `utils/tests`
46-
39. `utils/end`
47-
40. `utils/pack`
48-
41. `useContext`
49-
42. `context`
50-
43. `utils/step`
51-
44. `utils/apiStatistics`
52-
45. `utils/selectors`
53-
46. `selectors`
54-
47. `utils/log`
55-
48. `step`
56-
49. `utils/waitForEvents`
57-
50. `utils/expect`
58-
51. `expect`
59-
52. ...
31+
23. `utils/userland`
32+
24. `utils/fn`
33+
25. `utils/environment`
34+
26. `utils/packCompiler`
35+
27. `utils/config`
36+
28. `utils/generalLog`
37+
29. `utils/testFilePaths`
38+
30. `utils/exit`
39+
31. `utils/promise`
40+
32. `utils/resourceUsage`
41+
33. `utils/fs`
42+
34. `utils/completedTestRuns`
43+
35. `utils/getGlobalErrorHandler`
44+
36. `utils/tests`
45+
37. `utils/end`
46+
38. `utils/pack`
47+
39. `useContext`
48+
40. `context`
49+
41. `utils/step`
50+
42. `utils/apiStatistics`
51+
43. `utils/selectors`
52+
44. `selectors`
53+
45. `utils/log`
54+
46. `step`
55+
47. `utils/waitForEvents`
56+
48. `utils/expect`
57+
49. `expect`
58+
50. `config`
59+
60+
No module imports `config`, so it is at the very bottom of the graph: it is required only lazily,
61+
inside the body of `getFullPackConfig` from `utils/config` (a deliberate exception to the rule
62+
above), and Playwright reads it by the `CONFIG_PATH` file path (as the `--config` CLI argument),
63+
not by import.

‎src/constants/log.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ export const enum LogEventType {
3333
InternalCore = 7,
3434
InternalUtil = 8,
3535
Unspecified = 9,
36+
Given = 10,
37+
When = 11,
38+
Then = 12,
39+
And = 13,
40+
But = 14,
41+
// eslint-disable-next-line @typescript-eslint/naming-convention
42+
'*' = 15,
3643
}
3744

3845
/**

‎src/step.ts‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,57 @@ export const step = async (
9898
}
9999
}
100100
};
101+
102+
/**
103+
* Given step.
104+
*/
105+
export const Given = (
106+
name: string,
107+
body?: StepBody,
108+
options: Omit<StepOptions, 'type'> = {},
109+
): Promise<void> => step(name, body, {...options, type: LogEventType.Given});
110+
111+
/**
112+
* When step.
113+
*/
114+
export const When = (
115+
name: string,
116+
body?: StepBody,
117+
options: Omit<StepOptions, 'type'> = {},
118+
): Promise<void> => step(name, body, {...options, type: LogEventType.When});
119+
120+
/**
121+
* Then step.
122+
*/
123+
export const Then = (
124+
name: string,
125+
body?: StepBody,
126+
options: Omit<StepOptions, 'type'> = {},
127+
): Promise<void> => step(name, body, {...options, type: LogEventType.Then});
128+
129+
/**
130+
* And step.
131+
*/
132+
export const And = (
133+
name: string,
134+
body?: StepBody,
135+
options: Omit<StepOptions, 'type'> = {},
136+
): Promise<void> => step(name, body, {...options, type: LogEventType.And});
137+
138+
/**
139+
* But step.
140+
*/
141+
export const But = (
142+
name: string,
143+
body?: StepBody,
144+
options: Omit<StepOptions, 'type'> = {},
145+
): Promise<void> => step(name, body, {...options, type: LogEventType.But});
146+
147+
/**
148+
* Star step.
149+
*/
150+
export const Star = (
151+
name: string,
152+
body?: StepBody,
153+
options: Omit<StepOptions, 'type'> = {},
154+
): Promise<void> => step(name, body, {...options, type: LogEventType['*']});

‎src/types/codeReport.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import type {Feature} from 'parse-gherkin';
2+
3+
import type {Brand} from './brand';
4+
import type {SourceFile} from './fs';
5+
import type {ParsedTest} from './parseTest';
6+
7+
/**
8+
* Code report analyzing test and specification code, as well as the relationships between them.
9+
*/
10+
export type CodeReport = Readonly<{
11+
features: Readonly<Record<SourcePath, Feature>>;
12+
tests: Readonly<Record<SourcePath, ParsedTest>>;
13+
}>;
14+
15+
/**
16+
* Iterable stream of source files.
17+
*/
18+
export type SourceIterable = AsyncIterable<SourceFile> | Iterable<SourceFile>;
19+
20+
/**
21+
* Path to source file.
22+
*/
23+
export type SourcePath = Brand<string, 'SourcePath'>;

‎src/types/fs.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* Source file of any type.
3+
*/
4+
export type SourceFile = Readonly<{
5+
path: string;
6+
source: string;
7+
}>;

‎src/types/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ export type {Brand, IsBrand} from './brand';
1111
export type {Expect, IsArray, IsEqual, IsReadonlyKey, IsUnion} from './checks';
1212
export type {Class} from './class';
1313
export type {ClientFunction} from './clientFunction';
14+
export type {CodeReport, SourceIterable, SourcePath} from './codeReport';
1415
export type {BrowserName} from './config';
1516
export type {ConsoleMessage, ConsoleMessageType} from './console';
1617
export type {UtcTimeInMs} from './date';
1718
export type {DeepMutable, DeepPartial, DeepReadonly, DeepRequired} from './deep';
1819
export type {E2edPrintedFields, JsError} from './errors';
1920
export type {LogEvent, Onlog, TestRunEvent} from './events';
2021
export type {Fn, MergeFunctions} from './fn';
22+
export type {SourceFile} from './fs';
2123
export type {
2224
FullMocksConfig,
2325
FullMocksResponse,

‎src/types/internal.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export type {Brand, IsBrand} from './brand';
1515
export type {Expect, IsArray, IsEqual, IsReadonlyKey, IsUnion} from './checks';
1616
export type {Class} from './class';
1717
export type {ClientFunction} from './clientFunction';
18+
export type {CodeReport, SourceIterable, SourcePath} from './codeReport';
1819
export type {
1920
AnyPack,
2021
BrowserName,
@@ -35,6 +36,7 @@ export type {LogEvent, Onlog, TestRunEvent} from './events';
3536
/** @internal */
3637
export type {EndTestRunEvent, FullEventsData} from './events';
3738
export type {Fn, MergeFunctions} from './fn';
39+
export type {SourceFile} from './fs';
3840
export type {
3941
FullMocksConfig,
4042
FullMocksResponse,

‎src/types/projectSettings.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Common static project settings (general for all packs).
33
*/
44
export type ProjectSettings = Readonly<{
5+
allFeatureFileGlobs: readonly string[];
56
allTestFileGlobs: readonly string[];
67
dockerImage: string | null;
78
pathToTsConfigFromRoot: string;

0 commit comments

Comments
 (0)