Skip to content

Commit

Permalink
Broke up reporter tests to multiple tests
Browse files Browse the repository at this point in the history
  • Loading branch information
markwpearce committed Aug 13, 2024
1 parent 01e06a8 commit 32963d8
Showing 1 changed file with 33 additions and 11 deletions.
44 changes: 33 additions & 11 deletions bsc-plugin/src/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2161,16 +2161,18 @@ describe('RooibosPlugin', () => {
expect(findMethod('getIgnoredTestInfo').func.body.statements).to.be.empty;
});

const sep = '\n';
const params: [string[], string][] = [
[[], 'rooibos_ConsoleTestReporter'],
[['CONSOLE'], 'rooibos_ConsoleTestReporter'],
[['MyCustomReporter'], 'MyCustomReporter'],
[['JUnit', 'MyCustomReporter'], `rooibos_JUnitTestReporter${sep}MyCustomReporter`]
];

it('adds custom test reporters', async () => {
for (const [reporters, expected] of params) {

describe('test reporters', function runTests() {
this.timeout(5000);
const sep = '\n';
const params: [string[], string][] = [
[[], 'rooibos_ConsoleTestReporter'],
[['CONSOLE'], 'rooibos_ConsoleTestReporter'],
[['MyCustomReporter'], 'MyCustomReporter'],
[['JUnit', 'MyCustomReporter'], `rooibos_JUnitTestReporter${sep}MyCustomReporter`]
];

async function runReporterTest(reporters: string[], expected: string[]) {
setupProgram({
rootDir: _rootDir,
stagingDir: _stagingFolderPath,
Expand All @@ -2184,9 +2186,29 @@ describe('RooibosPlugin', () => {
await builder.build();
const content = getContents('rooibos/RuntimeConfig.brs');
const noLeadingWhitespace = content.replace(/^\s+/gm, '');
expect(noLeadingWhitespace).to.include(expected);
const actualLines = noLeadingWhitespace.split(sep);
const start = actualLines.slice(actualLines.indexOf('"reporters": [') + 1);
const actualReporters = start.slice(0, start.indexOf(']'));

expect(actualReporters).to.include.members(expected);
destroyProgram();
}

it('adds console reporter by default', async () => {
await runReporterTest([], ['rooibos_ConsoleTestReporter']);
});

it('recognizes console reporter, case insensitive', async () => {
await runReporterTest(['CONSOLE'], ['rooibos_ConsoleTestReporter']);
});

it('can add a custom reporter', async () => {
await runReporterTest(['MyCustomReporter'], ['MyCustomReporter']);
});

it('can add a multiple reporters, including Junit', async () => {
await runReporterTest(['Junit', 'MyCustomReporter'], ['rooibos_JUnitTestReporter', 'MyCustomReporter']);
});
});
});

Expand Down

0 comments on commit 32963d8

Please sign in to comment.