Skip to content

Commit 0f35ff8

Browse files
committed
Improve Cypress integration test performance and CI efficiency
- Add 'deleteFiles' custom command to batch file deletions, reducing costly 'cy.exec' calls in test setup and teardown. - Update 'pipeline.cy.ts' to use 'deleteFiles' for cleaning up multiple exported pipelines and test artifacts. - Make 'cy:run' headless to speed up CI runs and add 'cy:debug' for local headed test execution. - Add 'deleteFiles' to Cypress TypeScript definitions. Signed-off-by: Luciano Resende <[email protected]>
1 parent ec1f6a3 commit 0f35ff8

4 files changed

Lines changed: 33 additions & 17 deletions

File tree

cypress/support/commands.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ Cypress.Commands.add('deleteFile', (name: string): void => {
139139
});
140140
});
141141

142+
Cypress.Commands.add('deleteFiles', (names: string[]): void => {
143+
if (names.length === 0) {
144+
return;
145+
}
146+
const findCommands = names
147+
.map((name) => `-name "${name}"`)
148+
.join(' -o ');
149+
cy.exec(`find build/cypress/ \\( ${findCommands} \\) -delete`, {
150+
failOnNonZeroExit: false
151+
});
152+
});
153+
142154
Cypress.Commands.add(
143155
'createPipeline',
144156
({ name, type, emptyPipeline } = {}): void => {

cypress/support/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ declare namespace Cypress {
2727
type: 'kfp' | 'airflow';
2828
}): Chainable<void>;
2929
deleteFile(fileName: string): Chainable<void>;
30+
deleteFiles(fileNames: string[]): Chainable<void>;
3031
openDirectory(fileName: string): Chainable<void>;
3132
addFileToPipeline(fileName: string): Chainable<void>;
3233
dragAndDropFileToPipeline(fileName: string): Chainable<void>;

cypress/tests/pipeline.cy.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ const emptyPipeline = `{
3838

3939
describe('Pipeline Editor tests', () => {
4040
beforeEach(() => {
41-
cy.deleteFile('generic-test.yaml'); // previously exported pipeline
42-
cy.deleteFile('generic-test-custom.yaml'); // previously exported pipeline
43-
cy.deleteFile('generic-test.py'); // previously exported pipeline
44-
cy.deleteFile('*.pipeline'); // delete pipeline files used for testing
41+
cy.deleteFiles([
42+
'generic-test.yaml',
43+
'generic-test-custom.yaml',
44+
'generic-test.py',
45+
'*.pipeline'
46+
]);
4547

4648
cy.bootstrapFile('invalid.pipeline');
4749
cy.bootstrapFile('generic-test.pipeline');
@@ -55,18 +57,18 @@ describe('Pipeline Editor tests', () => {
5557
});
5658

5759
afterEach(() => {
58-
cy.deleteFile('helloworld.ipynb'); // delete notebook file used for testing
59-
cy.deleteFile('helloworld.py'); // delete python file used for testing
60-
cy.deleteFile('output.txt'); // delete output files generated by tests
61-
cy.deleteFile('*.pipeline'); // delete pipeline files used for testing
62-
cy.deleteFile('generic-test.yaml'); // exported pipeline
63-
cy.deleteFile('generic-test-custom.yaml'); // exported pipeline
64-
cy.deleteFile('generic-test.py'); // exported pipeline
65-
cy.deleteFile('invalid.txt');
66-
67-
// delete complex test directories
68-
cy.deleteFile('pipelines');
69-
cy.deleteFile('scripts');
60+
cy.deleteFiles([
61+
'helloworld.ipynb',
62+
'helloworld.py',
63+
'output.txt',
64+
'*.pipeline',
65+
'generic-test.yaml',
66+
'generic-test-custom.yaml',
67+
'generic-test.py',
68+
'invalid.txt',
69+
'pipelines',
70+
'scripts'
71+
]);
7072

7173
// delete runtime configurations used for testing
7274
cy.exec('elyra-metadata remove runtimes --name=kfp_test_runtime', {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"scripts": {
1414
"graph": "ts-node etc/scripts/generate-make-graph.ts",
1515
"cy:open": "npx cypress open",
16-
"cy:run": "npx nyc npx cypress run --headed",
16+
"cy:run": "npx nyc npx cypress run",
17+
"cy:debug": "npx nyc npx cypress run --headed",
1718
"eslint": "eslint . --fix --ignore-path .gitignore --ext .ts,.tsx,.js",
1819
"eslint:check": "eslint . --ignore-path .gitignore --ext .ts,.tsx,.js",
1920
"prettier": "prettier --ignore-path .gitignore --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json}\"",

0 commit comments

Comments
 (0)