2020-06-17 00:42:35 +08:00
|
|
|
import 'cypress-file-upload';
|
|
|
|
|
2020-06-02 01:55:37 +08:00
|
|
|
interface CompareScreenshotsConfig {
|
2020-06-01 20:48:23 +08:00
|
|
|
name: string;
|
2019-12-09 16:14:25 +08:00
|
|
|
threshold?: number;
|
|
|
|
}
|
|
|
|
|
2020-06-02 01:55:37 +08:00
|
|
|
Cypress.Commands.add('compareScreenshots', (config: CompareScreenshotsConfig | string) => {
|
|
|
|
cy.task('compareScreenshots', {
|
2020-06-01 20:48:23 +08:00
|
|
|
config,
|
|
|
|
screenshotsFolder: Cypress.config('screenshotsFolder'),
|
|
|
|
specName: Cypress.spec.name,
|
2019-12-09 16:14:25 +08:00
|
|
|
});
|
|
|
|
});
|
2019-12-10 16:47:03 +08:00
|
|
|
|
|
|
|
Cypress.Commands.add('logToConsole', (message: string, optional?: any) => {
|
2021-05-04 20:23:26 +08:00
|
|
|
cy.task('log', { message: '(' + new Date().toISOString() + ') ' + message, optional });
|
2019-12-10 16:47:03 +08:00
|
|
|
});
|
2020-03-27 00:15:58 +08:00
|
|
|
|
|
|
|
Cypress.Commands.add('readProvisions', (filePaths: string[]) => {
|
|
|
|
cy.task('readProvisions', {
|
|
|
|
CWD: Cypress.env('CWD'),
|
|
|
|
filePaths,
|
|
|
|
});
|
|
|
|
});
|
2021-09-29 22:27:49 +08:00
|
|
|
|
|
|
|
Cypress.Commands.add('getJSONFilesFromDir', (dirPath: string) => {
|
|
|
|
return cy.task('getJSONFilesFromDir', {
|
|
|
|
projectPath: Cypress.config().parentTestsFolder,
|
|
|
|
relativePath: dirPath,
|
|
|
|
});
|
|
|
|
});
|