Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
feat(protractor): Serenity/JS Cucumber adapter supports native Cucumb…
…er.js reporters protractor-cucumber-framework/protractor-cucumber-framework#73
- Loading branch information
Showing
11 changed files
with
135 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'mocha'; | ||
|
||
import { expect, ifExitCodeIsOtherThan, logOutput } from '@integration/testing-tools'; | ||
import { given } from 'mocha-testdata'; | ||
import { CucumberRunner, cucumberVersions } from '../src'; | ||
|
||
describe('@serenity-js/cucumber', function () { | ||
|
||
this.timeout(5000); | ||
|
||
given([ | ||
...cucumberVersions(1, 2) | ||
.thatRequires( | ||
'node_modules/@serenity-js/cucumber/lib/index.js', | ||
'lib/support/configure_serenity.js', | ||
) | ||
.withStepDefsIn('synchronous', 'promise', 'callback') | ||
.withArgs( | ||
'--no-colors', | ||
'--format', 'summary', | ||
) | ||
.toRun('features/passing_scenario.feature'), | ||
|
||
...cucumberVersions(3, 4, 5, 6) | ||
.thatRequires('lib/support/configure_serenity.js') | ||
.withStepDefsIn('synchronous', 'promise', 'callback') | ||
.withArgs( | ||
'--format', 'node_modules/@serenity-js/cucumber', | ||
'--format', 'summary', | ||
) | ||
.toRun('features/passing_scenario.feature'), | ||
]). | ||
it('supports native cucumber formatters', (runner: CucumberRunner) => runner.run(). | ||
then(ifExitCodeIsOtherThan(0, logOutput)). | ||
then(res => { | ||
expect(res.exitCode).to.equal(0); | ||
|
||
expect(res.stdout).to.match(/1 scenario.*?1 passed.*?\n1 step.*?1 passed/); | ||
})); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import 'mocha'; | ||
|
||
import { given } from 'mocha-testdata'; | ||
import { OperatingSystem } from '../../src/io'; | ||
import { expect } from '../expect'; | ||
|
||
/** @test {OperatingSystem} */ | ||
describe('OperatingSystem', () => { | ||
|
||
const | ||
windows = { os: { platform: () => 'win32' }, proc: { } }, | ||
msys = { os: { platform: () => 'linux' }, proc: { env: { OSTYPE: 'msys' } } }, | ||
cygwin = { os: { platform: () => 'linux' }, proc: { env: { OSTYPE: 'cygwin' } } }, | ||
linux = { os: { platform: () => 'linux' }, proc: { env: { } } }, | ||
macos = { os: { platform: () => 'darwin' }, proc: { env: { } } }; | ||
|
||
const | ||
nullDevice = '\\\\.\\NUL', | ||
devNull = '/dev/null'; | ||
|
||
given([ | ||
{ isWindows: true, ...windows }, | ||
{ isWindows: true, ...msys }, | ||
{ isWindows: true, ...cygwin }, | ||
{ isWindows: false, ...linux }, | ||
{ isWindows: false, ...macos }, | ||
]). | ||
it('recognises the type of the operating system', ({ os, proc, isWindows }: { os: any, proc: any, isWindows: boolean }) => { | ||
const operatingSystem = new OperatingSystem(os, proc); | ||
|
||
expect(operatingSystem.isWindows()).to.equal(isWindows); | ||
}); | ||
|
||
given([ | ||
{ expectedPath: nullDevice, ...windows }, | ||
{ expectedPath: nullDevice, ...msys }, | ||
{ expectedPath: nullDevice, ...cygwin }, | ||
{ expectedPath: devNull, ...linux }, | ||
{ expectedPath: devNull, ...macos }, | ||
]). | ||
it('tells the null device path', ({ expectedPath, os, proc }: { expectedPath: string, os: any, proc: any }) => { | ||
const operatingSystem = new OperatingSystem(os, proc); | ||
|
||
expect(operatingSystem.nullDevicePath()).to.equal(expectedPath); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import * as os from 'os'; | ||
|
||
export class OperatingSystem { | ||
constructor( | ||
private readonly operatingSystem: typeof os, | ||
private readonly proc: typeof process, | ||
) { | ||
} | ||
|
||
public nullDevicePath(): string { | ||
return this.isWindows() | ||
? `\\\\.\\NUL` | ||
: `/dev/null`; | ||
} | ||
|
||
public isWindows(): boolean { | ||
return this.operatingSystem.platform() === 'win32' | ||
|| /^(msys|cygwin)$/.test(this.proc.env.OSTYPE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters