Skip to content

Commit

Permalink
#132: Fix incorrectly typed message type arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
archfz committed Feb 6, 2022
1 parent e9b146e commit 59f0ab9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,10 @@ directory. You should add `it.only` to the test case you are working on to speed
## Release Notes
- Security update.
- Fix incorrectly typed message type arguments. [issue](https://github.com/archfz/cypress-terminal-report/issues/132)
- Security updates.
- Update cypress to 9.4.1 in tests to confirm support.
-
#### 3.4.1
- Add severity typescript types. [merge-request](https://github.com/archfz/cypress-terminal-report/pull/128) by [tebeco](https://github.com/tebeco)
Expand Down
21 changes: 17 additions & 4 deletions src/installLogsCollector.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
export type Severity = '' | 'error' | 'warning';
export type LogType = 'cons:log' |
'cons:info' |
'cons:warn' |
'cons:error' |
'cons:debug' |
'cy:log' |
'cy:xhr' |
'cy:fetch' |
'cy:request' |
'cy:route' |
'cy:intercept' |
'cy:command' |
'ctr:info';

export interface SupportOptions {
/**
Expand All @@ -17,7 +30,7 @@ export interface SupportOptions {
filterLog?:
| null
| NonNullable<SupportOptions['collectTypes']>[number]
| ((args: [/* type: */ Severity, /* message: */ string, /* severity: */ Severity]) => boolean);
| ((args: [/* type: */ LogType, /* message: */ string, /* severity: */ Severity]) => boolean);

/**
* Callback to process logs manually. The type is from the same list as for the collectTypes option.
Expand All @@ -27,15 +40,15 @@ export interface SupportOptions {
processLog?:
| null
| NonNullable<SupportOptions['collectTypes']>[number]
| ((args: [/* type: */ Severity, /* message: */ string, /* severity: */ Severity]) => [Severity, string, Severity]);
| ((args: [/* type: */ LogType, /* message: */ string, /* severity: */ Severity]) => [Severity, string, Severity]);

/**
* Callback to collect each test case's logs after its run.
* @default undefined
*/
collectTestLogs?: (
context: {mochaRunnable: any, testState: string, testTitle: string, testLevel: number},
messages: [/* type: */ Severity, /* message: */ string, /* severity: */ Severity][]
messages: [/* type: */ LogType, /* message: */ string, /* severity: */ Severity][]
) => void;

xhr?: {
Expand Down Expand Up @@ -67,4 +80,4 @@ export interface SupportOptions {
}

declare function installLogsCollector(config?: SupportOptions): void;
export = installLogsCollector;
export default installLogsCollector;
19 changes: 16 additions & 3 deletions src/installLogsPrinter.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
/// <reference types="cypress" />

export type Severity = '' | 'error' | 'warning';
export type LogType = 'cons:log' |
'cons:info' |
'cons:warn' |
'cons:error' |
'cons:debug' |
'cy:log' |
'cy:xhr' |
'cy:fetch' |
'cy:request' |
'cy:route' |
'cy:intercept' |
'cy:command' |
'ctr:info';

export interface PluginOptions {
/**
Expand Down Expand Up @@ -41,7 +54,7 @@ export interface PluginOptions {
string,
| 'json'
| 'txt'
| ((messages: Record<string, Record<string, [string, string, Severity]>>) => string)
| ((messages: Record<string, Record<string, [LogType, string, Severity]>>) => string)
>;

/**
Expand Down Expand Up @@ -80,8 +93,8 @@ export interface PluginOptions {
* Callback to collect each test case's logs after its run.
* @default undefined
*/
collectTestLogs?: (context: {spec: string, test: string, state: string}, messages: [/* type: */ Severity, /* message: */ string, /* severity: */ Severity][]) => void;
collectTestLogs?: (context: {spec: string, test: string, state: string}, messages: [/* type: */ LogType, /* message: */ string, /* severity: */ Severity][]) => void;
}

declare function installLogsPrinter(on: Cypress.PluginEvents, options?: PluginOptions): void;
export = installLogsPrinter;
export default installLogsPrinter;

0 comments on commit 59f0ab9

Please sign in to comment.