Skip to content

Commit

Permalink
fix: typings for test labels
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph committed Dec 28, 2023
1 parent 90673e3 commit e238639
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
23 changes: 4 additions & 19 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,6 @@ declare module 'jest-allure2-reporter' {
plugins: Promise<Plugin[]>;
};

export type _LabelName =
| 'package'
| 'testClass'
| 'testMethod'
| 'parentSuite'
| 'suite'
| 'subSuite'
| 'epic'
| 'feature'
| 'story'
| 'thread'
| 'severity'
| 'tag'
| 'owner';

export type AttachmentsOptions = {
/**
* Defines a subdirectory within the {@link ReporterOptions#resultsDir} where attachments will be stored.
Expand Down Expand Up @@ -210,8 +195,8 @@ declare module 'jest-allure2-reporter' {
labels:
| TestCaseExtractor<Label[]>
| Record<
_LabelName | string,
TestCaseExtractor<string[], string | string[]>
LabelName | string,
string | string[] | TestCaseExtractor<string[], string | string[]>
>;
/**
* Resolve issue links for the test case.
Expand Down Expand Up @@ -305,8 +290,8 @@ declare module 'jest-allure2-reporter' {
labels:
| TestFileExtractor<Label[]>
| Record<
_LabelName | string,
TestFileExtractor<string[], string | string[]>
LabelName | string,
string | string[] | TestFileExtractor<string[], string | string[]>
>;
/**
* Resolve issue links for the test file.
Expand Down
2 changes: 1 addition & 1 deletion package-e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"description": "",
"scripts": {
"test": "node test.cjs && node test.mjs && tsc",
"test": "node test.cjs && node test.mjs && tsc && tsc -p tsconfig.isolated.json",
"test:cjs": "node test.cjs",
"test:mjs": "node test.mjs",
"test:ts": "tsc && tsc -p tsconfig.isolated.json"
Expand Down
20 changes: 20 additions & 0 deletions package-e2e/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@ assertType<ReporterOptions>({
subDir: 'attachments',
fileHandler: 'copy',
},
testFile: {
labels: {
tag: ['unit', 'javascript'],
package: 'Some Package',
severity: (context) => context.value ?? 'critical',
},
links: {
github: ({ filePath }) => ({
name: 'GitHub',
url: `https://github.com/owner/repo/tree/master/${filePath.join('/')}`,
}),
},
},
testCase: {
labels: {
tag: ['unit', 'javascript'],
severity: 'normal',
story: () => 'Some Story',
},
},
});

assertType<Function>($Owner);
Expand Down

0 comments on commit e238639

Please sign in to comment.