Index

src/tools/path-replacement/path-replacement.ts

adjustPath
adjustPath(frameworkName, customTransformOptions: TransformOptions)

Switch to the needed implementation of core testing, when running e2e tests transforms ESM into CJS when needed

Parameters :
Name Type Optional Default value Description
frameworkName No

Name of the framework used for e2e testing (playwright|protractor)

customTransformOptions TransformOptions No {}

src/store/testable-select.ts

clearSelectorSpies
clearSelectorSpies()

PUBLIC METHODS

clearSelectorSpy
clearSelectorSpy(selector: SelectorFunction)

Removes the spy on a given selector function

Parameters :
Name Type Optional Description
selector SelectorFunction No

Selector function that is being spied on

initializeSelectorSpies
initializeSelectorSpies()

Initialize the selector spies structure

select
select(selectFn: SelectorFunction, props?)

Highjacked ngrx/store select. It checks if the selector function is being spied on and returns it's fake result. Otherwise, it runs the original ngrx/store select

Parameters :
Name Type Optional Description
selectFn SelectorFunction No

Selector function to be used

props Yes

optional properties to be used by the selector

spyOnSelector
spyOnSelector(selector: SelectorFunction, fakeResult)

Spy on a selector function

Parameters :
Name Type Optional Description
selector SelectorFunction No

Selector function to be spied on

fakeResult No

The fake result to be used when a select is triggered

useSpy
useSpy(spy: SelectorSpy)

Uses the spy as the return of a select

Parameters :
Name Type Optional Description
spy SelectorSpy No

The selector spy

Returns : Observable<R>

src/visual-test/visual-test.ts

compareScreenshot
compareScreenshot(screenshot: string, baseImagePath: string, threshold: number, pathToScenarioReport: string)

Compare images helper function. If the comparison fails the 3 images (base/new/diff) will be written inside the reports folder of the actual scenario

Parameters :
Name Type Optional Description
screenshot string No

Actual captured screenshot object

baseImagePath string No

The path to the base screenshot

threshold number No

The diff between base screenshot and the current one should not be bigger than this value.

pathToScenarioReport string No

Path where the scenario report is saved inside reports folder. Used to compute the path to write diff images in case there is a diff at comparison

Returns : VisualTestResult

An object of visual test result type

o3rVisualTest
o3rVisualTest(screenshotObj: string, filenameWithoutExtension: string, device: string, scenarioName: string, pathToScenarioReport: string, threshold: number, generateMode, baseScreenshotsDirPath: string)

Helper function to perform a visual test operation

Parameters :
Name Type Optional Default value Description
screenshotObj string No

Ex: for protractor browser.takeScreenshot()

filenameWithoutExtension string No

file name to save the screenshot - .png will be added at the end

device string No

os followed by browser version - ex: Windows 10 chrome 89

scenarioName string No

E2e Scenario class name

pathToScenarioReport string No 'reports'

Path used in compare mode for saving the base,new,diff images in reports in case there is a diff

threshold number No 0

The diff between base screenshot and the current one should not be bigger than this value. If the diff is bigger, 3 png files will be created: base screenshot, new screenshot and diff image

generateMode No false

If true it will generate the screenshot file without screenshots comparison

baseScreenshotsDirPath string No 'dist-screenshots-base'

The folder path to search base screenshots; used only in compare mode

saveScreenshot
saveScreenshot(screenshot: string, scenarioName: string, device: string, filenameWithoutExtension: string, distScreenshotsDir: string)

It will create a file for the passed screenshot object. The path of the new file will be calculated using the parameters Ex: ./dist-screenshots\OWBooking\windows_chrome_91\fare-page-after-click-on-continue-0.png distScreenshotsDir/scenarionName/device/filenameWithoutExtension.png

Parameters :
Name Type Optional Default value Description
screenshot string No

The screenshot object captured. Ex: for protractor - browser.takeScreenshot()

scenarioName string No

E2e Scenario class name

device string No

Details of the platform on which the test is run. If there are spaces the helper will do the concatenation. Ex: Windows 10 chrome 89

filenameWithoutExtension string No

file name to save the screenshot - .png will be added at the end

distScreenshotsDir string No 'dist-screenshots'

Name of the directory to save the screenshots

toBeVisuallySimilar
toBeVisuallySimilar()

Visual test matcher Based on the VisualTestResult object return by compareScreenshots function, this matcher will compute the error messages

writeScreenshotsDiff
writeScreenshotsDiff(pathToScenarioReport: string, screenshotsDirName: string, diff: PNG, baseImage: PNG, currentImg: PNG)

Write the 3 images (base/new/diff) on the reports folder The path inside the reports forlder will be calculated using the parameters

Parameters :
Name Type Optional Description
pathToScenarioReport string No

Path where the scenario report is saved inside reports folder

screenshotsDirName string No

Name of the directory which will contain the 3 images

diff PNG No

diff image

baseImage PNG No

the base image

currentImg PNG No

the actual taken screenshot image

src/core/protractor/utils.ts

convertPromise
Will be removed in v13, please use Playwright instead
convertPromise(promise)

Converts a webdriver promise to ES6 promise so the rest of the framework handles ES6 promises only

Parameters :
Name Optional
promise No

src/mocks/mock-component-generator.ts

generateMockComponent
generateMockComponent(componentPath: string, config?)

Generate a mock class base on a component file

Parameters :
Name Type Optional Description
componentPath string No

Path to the component file to mock

config Yes

Object containing the following configurations: template: should be provided if the template contain <ng-content></ng-content> isControlValueAccessor: should be provided if the component extends ControlValueAccessor

Returns : Type<T>
getIOName
getIOName(currentNode, decorator, source)

Get the name of the input / output

Parameters :
Name Optional Description
currentNode No

Typescript AST Node

decorator No

Current Input/Output decorator node

source No

Typescript source file

Returns : string | undefined
getSelector
getSelector(parentNode, source, isInDecorator, isInComponentConfig)

Get the selector of an angular class

Parameters :
Name Optional Default value Description
parentNode No

Typescript AST Node

source No

Typescript source file

isInDecorator No false

true if the recursive execution is in a decorator

isInComponentConfig No false

true if the recursive execution is in a component decorator configuration

isInputNode
isInputNode(node, source)

Determine if the node in an input field

Parameters :
Name Optional Description
node No

Typescript AST Node

source No

Typescript source file

Returns : ts.Decorator
isOutputNode
isOutputNode(node, source)

Determine if the node in an output field

Parameters :
Name Optional Description
node No

Typescript AST Node

source No

Typescript source file

Returns : ts.Decorator
parseIO
parseIO(parentNode, source)

Get the list of Input and Output of a component

Parameters :
Name Optional Description
parentNode No

Typescript AST Node

source No

Typescript source file

Returns : literal type

src/core/playwright/element.ts

getPlainText
getPlainText(innerText: string)

Remove text formatting (endline etc.) and return the content.

Parameters :
Name Type Optional
innerText string No

src/tools/protractor/fetch-manager/utils.ts

initFetchManager
Will be removed in v13, please use Playwright instead
initFetchManager()

This function initiliaze the FetchManager. Set window.fetch variable with a custom behaviour in order to count the fetch calls.

stopFetchManager
Will be removed in v13, please use Playwright instead
stopFetchManager()

This function stops the FetchManager. Reset window.fetch variable with its native behaviour.

waitForOtterStable
Will be removed in v13, please use Playwright instead
waitForOtterStable()

This function waits for all fetchs calls to be resolved and the page to be stable to resolve the promise. It permits to easily run synchronous e2e tests on a flow that uses fetchs calls with protractor. This is very useful in the case of Otter calls to backend because protractor synchronization manager do not care about fetchs calls.

This function needs the FetchManager to have been initialized and injected in the browser at the beginning of the flow with initFetchManager()

You can ignore the waiting of fetchs by setting browser.ignoreSynchronization to true

src/store/typings.ts

isSelectorSpyCall
isSelectorSpyCall(spy: SelectorSpy)

Identifies if spy is a spyResult or spyCall

Parameters :
Name Type Optional
spy SelectorSpy No
Returns : SelectorSpyCall<R>

src/visual-test/utils.ts

isVisualTestingEnabled
isVisualTestingEnabled()

Determine if the visual testing is enabled

prepareVisualTesting
prepareVisualTesting(ignoreClass: string)

Prepare css rule to hide specific blocks

Should be called only once during the visual test.

Parameters :
Name Type Optional Default value
ignoreClass string No 'e2e-ignore'
toggleVisualTestingRender
toggleVisualTestingRender(enabled: boolean)

Toggle the visual testing view : if it is active, will hide tagged components as grey blocks.

Parameters :
Name Type Optional
enabled boolean No

src/localization/localization-mock.ts

mockTranslationModules
mockTranslationModules(localizationConfiguration: Partial, translations: MockTranslations, translationCompilerProvider?: Provider, mockPipe, pipeWithPrefix)

Function to get the list of modules required to test component using Localization module

Parameters :
Name Type Optional Default value Description
localizationConfiguration Partial No defaultLocalizationConfiguration

Localization configuration

translations MockTranslations No {}

Translations to use

translationCompilerProvider Provider Yes

Provider for translations compiler

mockPipe No false

Enable translation pipe mocking

pipeWithPrefix No false

Enable pipe with prefix

Returns : ModuleWithProviders[]

List of modules to import in the TestBed

src/kassette/update-dates-in-mocks.ts

updateDatesInMocks
updateDatesInMocks(mock: IMock, inputOptions: Partial)

Update mock checksum and response body to keep using the same mocks every day with updated dates

Parameters :
Name Type Optional Default value Description
mock IMock No

the mock instance provided by the hook method of Kassette

inputOptions Partial No {}

default options will extract ISO strings and use 'day-offset' mode

results matching ""

    No results matching ""