Skip to content

Commit 21ac3db

Browse files
committed
feat(integration-test-runner): Add Cypress
Fix PR comments - Refactor config to js to be able to read port from aurelia config - Remove title test due to inconsistency in skeleton - Add different test setup for navigation feature
1 parent cabe6ce commit 21ac3db

File tree

9 files changed

+92
-42
lines changed

9 files changed

+92
-42
lines changed

lib/commands/new/buildsystems/general/integration-test-runner/cypress.js

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,69 @@ const ProjectItem = require('../../../../../project-item').ProjectItem;
44
module.exports = function(project) {
55
const cypressResourceFolder = 'test/cypress';
66
const isUsingTypescript = project.model.transpiler.id === 'typescript';
7+
const isUsingNavigationFeature = !!project.model.features.navigation;
78

89
if (isUsingTypescript) {
9-
project.addToDevDependencies(
10-
'@cypress/webpack-preprocessor'
11-
);
10+
project.addToDevDependencies('@cypress/webpack-preprocessor');
1211
}
1312

1413
const testDirResources = [
1514
ProjectItem.directory('fixtures').add(
16-
ProjectItem.resource('example.json', `${cypressResourceFolder}/fixtures/example.json`)
15+
ProjectItem.resource(
16+
'example.json',
17+
`${cypressResourceFolder}/fixtures/example.json`
18+
)
1719
),
1820
ProjectItem.directory('integration').add(
19-
ProjectItem.resource('app.e2e.ext', `${cypressResourceFolder}/integration/app.e2e.ext`, project.model.transpiler)
21+
ProjectItem.resource(
22+
'app.e2e.ext',
23+
`${cypressResourceFolder}/integration/app${isUsingNavigationFeature ? '-navigation' : ''}.e2e.ext`,
24+
project.model.transpiler
25+
)
2026
),
2127
ProjectItem.directory('plugins').add(
22-
ProjectItem.resource('index.js', `${cypressResourceFolder}/plugins/index.ext`, project.model.transpiler)
28+
ProjectItem.resource(
29+
'index.js',
30+
`${cypressResourceFolder}/plugins/index.ext`,
31+
project.model.transpiler
32+
)
2333
),
2434
ProjectItem.directory('screenshots'),
2535
ProjectItem.directory('support').add(
26-
ProjectItem.resource('index.js', `${cypressResourceFolder}/support/index.js`),
27-
ProjectItem.resource('commands.ext', `${cypressResourceFolder}/support/commands.ext`, project.model.transpiler)
36+
ProjectItem.resource(
37+
'index.js',
38+
`${cypressResourceFolder}/support/index.js`
39+
),
40+
ProjectItem.resource(
41+
'commands.ext',
42+
`${cypressResourceFolder}/support/commands.ext`,
43+
project.model.transpiler
44+
)
2845
),
2946
ProjectItem.directory('videos')
3047
];
3148

3249
if (isUsingTypescript) {
33-
testDirResources.push(ProjectItem.resource('tsconfig.json', `${cypressResourceFolder}/tsconfig.json`));
50+
testDirResources.push(
51+
ProjectItem.resource(
52+
'tsconfig.json',
53+
`${cypressResourceFolder}/tsconfig.json`
54+
)
55+
);
3456
}
3557

36-
project.addToTasks(
37-
ProjectItem.resource('cypress.ext', 'tasks/cypress.ext', project.model.transpiler),
38-
ProjectItem.resource('cypress.json', 'tasks/cypress.json')
39-
).addToDevDependencies(
40-
'cypress'
41-
).addToContent(
42-
ProjectItem.resource('cypress.json', 'content/cypress.json'),
43-
project.tests.add(
44-
project.e2eTests.add(...testDirResources)
58+
project
59+
.addToTasks(
60+
ProjectItem.resource(
61+
'cypress.ext',
62+
'tasks/cypress.ext',
63+
project.model.transpiler
64+
),
65+
ProjectItem.resource('cypress.json', 'tasks/cypress.json')
4566
)
46-
);
67+
.addToDevDependencies('cypress')
68+
.addToContent(
69+
ProjectItem.resource('cypress.config.js', 'content/cypress.config.js'),
70+
project.tests.add(project.e2eTests.add(...testDirResources))
71+
);
4772
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const aureliaConfig = require('./aurelia_project/aurelia.json');
2+
const port = aureliaConfig.platform.port;
3+
4+
module.exports = {
5+
config: {
6+
baseUrl: `http://localhost:${port}`,
7+
fixturesFolder: 'test/e2e/fixtures',
8+
integrationFolder: 'test/e2e/integration',
9+
pluginsFile: 'test/e2e/plugins/index.js',
10+
screenshotsFolder: 'test/e2e/screenshots',
11+
supportFile: 'test/e2e/support/index.js',
12+
videosFolder: 'test/e2e/videos'
13+
}
14+
};

lib/resources/content/cypress.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

lib/resources/tasks/cypress.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import cypress from 'cypress';
22
import { CLIOptions } from 'aurelia-cli';
3+
import config from '../../cypress.config';
34

45
export default () => {
56
if (CLIOptions.hasFlag('run')) {
6-
cypress.run();
7+
cypress.run(config);
78
} else {
8-
cypress.open();
9+
cypress.open(config);
910
}
10-
}
11+
};

lib/resources/tasks/cypress.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import * as cypress from 'cypress';
22
import { CLIOptions } from 'aurelia-cli';
3+
import * as config from '../../cypress.config';
34

45
export default () => {
56
if (CLIOptions.hasFlag('run')) {
6-
cypress.run();
7+
cypress.run(config);
78
} else {
8-
cypress.open();
9+
cypress.open(config);
910
}
10-
}
11+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
describe('Aurelia navigation app', () => {
2+
beforeEach(() => {
3+
cy.visit('/');
4+
});
5+
6+
it('should load the page and display the initial page title', () => {
7+
cy.title().should('equal', 'Welcome | Aurelia');
8+
});
9+
10+
it('should display greeting', () => {
11+
cy.get('h2').contains('Welcome to the Aurelia Navigation App!');
12+
});
13+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
describe('Aurelia navigation app', () => {
2+
beforeEach(() => {
3+
cy.visit('/');
4+
});
5+
6+
it('should load the page and display the initial page title', () => {
7+
cy.title().should('equal', 'Welcome | Aurelia');
8+
});
9+
10+
it('should display greeting', () => {
11+
cy.get('h2').contains('Welcome to the Aurelia Navigation App!');
12+
});
13+
});

lib/resources/test/cypress/integration/app.e2e.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ describe('Aurelia skeleton app', () => {
33
cy.visit('/');
44
});
55

6-
it('should load the page and display the initial page title', () => {
7-
cy.title().should('equal', 'Aurelia Navigation Skeleton');
8-
});
9-
106
it('should display greeting', () => {
117
cy.get('h1').contains('Hello World!');
128
});

lib/resources/test/cypress/integration/app.e2e.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ describe('Aurelia skeleton app', () => {
33
cy.visit('/');
44
});
55

6-
it('should load the page and display the initial page title', () => {
7-
cy.title().should('equal', 'Aurelia Navigation Skeleton');
8-
});
9-
106
it('should display greeting', () => {
117
cy.get('h1').contains('Hello World!');
128
});

0 commit comments

Comments
 (0)