Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Wdio reporter output dir #694

Merged
merged 7 commits into from
Aug 16, 2021
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
3 changes: 3 additions & 0 deletions packages/terra-functional-testing/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* Changed
* Update fileReporter to accept outputDir config option

## 2.2.0 - (August 13, 2021)

* Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ class FileOutputReporter extends SpecReporter {
constructor(options) {
super({ stdout: true, ...options });
this.runners = [];
this.outputDir = options.outputDir || 'wdio';
this.resultJsonObject = {
startDate: '',
type: 'wdio',
locale: '',
formFactor: '',
theme: '',
cloudRegion: '',
output: {},
endDate: '',
};
Expand All @@ -36,7 +38,7 @@ class FileOutputReporter extends SpecReporter {
* @return null;
*/
setResultsDir() {
this.resultsDir = path.join(process.cwd(), 'tests', 'wdio', 'reports');
this.resultsDir = path.join(process.cwd(), 'tests', this.outputDir, 'reports');
}

/**
Expand Down Expand Up @@ -64,6 +66,7 @@ class FileOutputReporter extends SpecReporter {
formFactor,
locale,
theme,
cloudRegion,
} = options;

const fileNameConf = ['fileOutput'];
Expand All @@ -83,6 +86,10 @@ class FileOutputReporter extends SpecReporter {
fileNameConf.push(browserName);
}

if (cloudRegion) {
fileNameConf.push(cloudRegion);
}

if (cid) {
fileNameConf.push(cid);
}
Expand All @@ -99,6 +106,7 @@ class FileOutputReporter extends SpecReporter {
formFactor,
locale,
theme,
cloudRegion,
} = options;

if (locale) {
Expand All @@ -112,6 +120,10 @@ class FileOutputReporter extends SpecReporter {
if (formFactor) {
this.resultJsonObject.formFactor = formFactor;
}

if (cloudRegion) {
this.resultJsonObject.cloudRegion = cloudRegion;
}
}

/**
Expand Down Expand Up @@ -188,13 +200,19 @@ class FileOutputReporter extends SpecReporter {
const { cid, capabilities } = runner;
const { browserName } = capabilities;
const { config } = global.browser;
const { formFactor, locale, theme } = config.launcherOptions;
const {
formFactor,
locale,
theme,
cloudRegion,
} = config.launcherOptions;
const options = {
browserName,
cid,
formFactor,
locale,
theme,
cloudRegion,
};

this.buildFileName(options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('FileOutputReporter', () => {
formFactor: 'tiny',
locale: 'en',
theme: 'default',
cloudRegion: 'dev',
},
},
};
Expand All @@ -35,6 +36,7 @@ describe('FileOutputReporter', () => {
expect(reporter.resultJsonObject).toHaveProperty('startDate');
expect(reporter.resultJsonObject).toHaveProperty('endDate');
expect(reporter.resultJsonObject).toHaveProperty('type');
expect(reporter.resultJsonObject).toHaveProperty('cloudRegion');
expect(typeof reporter.resultJsonObject.output).toEqual('object');
});

Expand All @@ -54,6 +56,12 @@ describe('FileOutputReporter', () => {
const reporter = new FileOutputReporter({ writeStream: {} });
expect(reporter.resultsDir).toEqual(expect.stringContaining('tests/wdio/reports'));
});

it('set provided outputDir ', () => {
fs.existsSync.mockReturnValue(false);
const reporter = new FileOutputReporter({ writeStream: {}, outputDir: 'other' });
expect(reporter.resultsDir).toEqual(expect.stringContaining('tests/other/reports'));
});
});

describe('ensures results dir exists', () => {
Expand Down Expand Up @@ -138,6 +146,22 @@ describe('FileOutputReporter', () => {

expect(reporter.fileName).toEqual('fileOutput-en-default-tiny-chrome-0-1');
});

it('sets file name with locale, theme, formFactor, browser, cloudRegion, and cid', () => {
const reporter = new FileOutputReporter({ writeStream: {} });
const options = {
browserName: 'chrome',
cid: '0-1',
formFactor: 'tiny',
locale: 'en',
theme: 'default',
cloudRegion: 'dev',
};

reporter.buildFileName(options);

expect(reporter.fileName).toEqual('fileOutput-en-default-tiny-chrome-dev-0-1');
});
});

describe('updateResultObject', () => {
Expand Down Expand Up @@ -200,6 +224,7 @@ describe('FileOutputReporter', () => {
locale: 'en',
theme: 'terra-default-theme',
formFactor: 'small',
cloudRegion: 'dev',
},
},
};
Expand Down
1 change: 1 addition & 0 deletions packages/terra-toolkit-docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Pulling in next mvb of webpack-config-terra.

* Added
* Update FileOutputReporter docs to include cloudRegion
* webpack-config-terra v2 upgrade guide.
* Removed polyfill doc.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Wdio File Output Reporter is a reporter that logs wdio test output to separate f

- Date and time of when the tests are started and when they are finished

- Locale, Form Factor, and Theme of the tests
- Locale, Form Factor, Theme, and Cloud Region (if provided by full stack wdio configuration) of the tests

- Name of the tests and whether they've succeeded or failed

Expand All @@ -16,8 +16,8 @@ Wdio File Output Reporter assumes mono-repo will have packages directory in the

## Report Format

- The name of the log file for non-monorepo will be **result-\<locale>-\<theme>-\<form-factor>-\<browser>-\<cid>-\<repo-name>.json**(eg: result-en-huge-chrome-0-1-terra-toolkit-boneyard.json)
- The name of the log file for non-monorepo will be **result-\<locale>-\<theme>-\<form-factor>-\<browser>-\<cloudRegion>-\<cid>-\<repo-name>.json**(eg: result-en-huge-chrome-dev-0-1-terra-toolkit-boneyard.json)

- The name of the log file for mono-repo will be **result-\<locale>-\<theme>-\<form-factor>-\<browser>-\<cid>-\<Package-name>.json**(eg: fileOutput-en-terra-default-theme-large-chrome-1-0-terra-functional-testing.json)
- The name of the log file for mono-repo will be **result-\<locale>-\<theme>-\<form-factor>-\<browser>-\<cloudRegion>-\<cid>-\<Package-name>.json**(eg: fileOutput-en-terra-default-theme-large-chrome-dev-1-0-terra-functional-testing.json)

- Example output [a relative link](fileOutput-reporter-sample-result.json)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"locale": "en",
"theme": "terra-default-theme",
"formFactor": "large",
"cloudRegion": "dev",
"output": [
"------------------------------------------------------------------\n[chrome 69.0.3497.100 Linux #1-0] Spec: /Users/sn081183/Desktop/terra/terra-toolkit/packages/terra-functional-testing/tests/wdio/dispatch-custom-event-spec.js\n[chrome 69.0.3497.100 Linux #1-0] Running: chrome (v69.0.3497.100) on Linux\n[chrome 69.0.3497.100 Linux #1-0] Session ID: 28abf34875b0ae678fd50f6219b85036\n[chrome 69.0.3497.100 Linux #1-0]\n[chrome 69.0.3497.100 Linux #1-0] dispatchCustomEvent\n[chrome 69.0.3497.100 Linux #1-0] ✓ sends a custom event that injects a string into a paragraph\n[chrome 69.0.3497.100 Linux #1-0]\n"
],
Expand Down