-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Onboard cypress with component test runner (#34)
* feat: Onboard cypress with component test runner * Backfill on missing gestures tests. Was not able to get panning to work since triggering mousedown and mousemove are not propagating the event to the gesture handler. * Add styles to rendered charts Co-authored-by: Norbert Nader <nnader@amazon.com>
- Loading branch information
1 parent
bd18486
commit b82d682
Showing
17 changed files
with
341 additions
and
18 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
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,12 @@ | ||
{ | ||
"component": { | ||
"videoUploadOnPasses": false, | ||
"video": true, | ||
"viewportWidth": 400, | ||
"viewportHeight": 500, | ||
"watchForFileChanges": true, | ||
"defaultCommandTimeout": 8000, | ||
"componentFolder": "src", | ||
"testFiles": "**/*.spec.component.ts" | ||
} | ||
} |
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,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "hello@cypress.io", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
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,16 @@ | ||
const { startDevServer } = require('@cypress/webpack-dev-server') | ||
const webpackConfig = require('@vue/cli-service/webpack.config.js') | ||
const { addMatchImageSnapshotPlugin } = require('cypress-image-snapshot/plugin'); | ||
|
||
module.exports = (on, config) => { | ||
on('dev-server:start', options => | ||
startDevServer({ | ||
options, | ||
webpackConfig | ||
}) | ||
) | ||
|
||
addMatchImageSnapshotPlugin(on, config); | ||
|
||
return config | ||
} |
Binary file added
BIN
+21.7 KB
...hots/components/iot-connector/iot-connector.spec.component.ts/zooms in.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+13.3 KB
...ots/components/iot-connector/iot-connector.spec.component.ts/zooms out.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,15 @@ | ||
export const addChartCommands = () => { | ||
Cypress.Commands.add( | ||
'matchImageSnapshotOnCI', | ||
{ prevSubject: 'optional' }, | ||
(subject, nameOrOptions?: string | Object) => { | ||
if (!Cypress.env('disableSnapshotTests')) { | ||
if (subject) { | ||
cy.wrap(subject).matchImageSnapshot(nameOrOptions); | ||
} else { | ||
cy.matchImageSnapshot(nameOrOptions); | ||
} | ||
} | ||
} | ||
); | ||
}; |
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,9 @@ | ||
import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command'; | ||
import { addChartCommands } from './chartCommands'; | ||
|
||
addChartCommands(); | ||
|
||
addMatchImageSnapshotCommand({ | ||
failureThreshold: 0.025, | ||
failureThresholdType: 'percent', | ||
}); |
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,11 @@ | ||
/* eslint-disable */ | ||
/// <reference types="cypress" /> | ||
|
||
declare namespace Cypress { | ||
interface Chainable<Subject> { | ||
/** | ||
* Custom command to wait until a chart is done with it's initial rendering | ||
*/ | ||
matchImageSnapshotOnCI(nameOrOptions?: string | Object): void; | ||
} | ||
} |
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 @@ | ||
// *********************************************************** | ||
// This example support/index.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
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,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"baseUrl": "../node_modules", | ||
"target": "es5", | ||
"lib": ["es2019", "dom"], | ||
"types": ["cypress", "@types/cypress-image-snapshot"] | ||
}, | ||
"include": [ | ||
"**/*.ts" | ||
] | ||
} |
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
28 changes: 28 additions & 0 deletions
28
packages/components/src/components/iot-connector/iot-connector.spec.component.ts
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,28 @@ | ||
import { renderChart, testChartContainerClassNameSelector } from '@iot-app-kit/components/src/testing/renderChart'; | ||
import { SECOND_IN_MS } from '@iot-app-kit/core/src/common/time'; | ||
|
||
describe('handles gestures', () => { | ||
it('zooms in and out', () => { | ||
renderChart(); | ||
|
||
cy.wait(SECOND_IN_MS * 2); | ||
|
||
cy.get(testChartContainerClassNameSelector).dblclick(); | ||
|
||
cy.wait(SECOND_IN_MS * 2); | ||
|
||
cy.matchImageSnapshotOnCI('zooms in'); | ||
|
||
cy.get(testChartContainerClassNameSelector).dblclick({ shiftKey: true }); | ||
|
||
cy.wait(SECOND_IN_MS * 2); | ||
|
||
cy.get(testChartContainerClassNameSelector).dblclick({ shiftKey: true }); | ||
|
||
cy.wait(SECOND_IN_MS * 2); | ||
|
||
cy.matchImageSnapshotOnCI('zooms out'); | ||
}); | ||
|
||
// TODO: Panning - can not get the chart to pan with cypress trigger https://docs.cypress.io/api/commands/trigger#Usage | ||
}); |
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
Oops, something went wrong.