-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: E2E Trace-Based Testing * adding npm packages * adding npm packages * updates * adding custom config support
- Loading branch information
Showing
23 changed files
with
4,900 additions
and
26,835 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
TRACETEST_API_TOKEN= | ||
POKESHOP_DEMO_URL= |
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 |
---|---|---|
|
@@ -6,3 +6,7 @@ helm-chart/charts/ | |
node_modules/ | ||
api/.build/ | ||
.idea/ | ||
.DS_Store | ||
.env | ||
|
||
cypress/screenshots |
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
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,17 @@ | ||
import { defineConfig } from 'cypress'; | ||
import { config } from 'dotenv'; | ||
|
||
config(); | ||
|
||
module.exports = defineConfig({ | ||
chromeWebSecurity: false, | ||
e2e: { | ||
baseUrl: process.env.POKESHOP_DEMO_URL || 'http://localhost:3000', | ||
env: { | ||
TRACETEST_API_TOKEN: process.env.TRACETEST_API_TOKEN, | ||
}, | ||
setupNodeEvents() { | ||
// implement node event listeners here | ||
}, | ||
}, | ||
}); |
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,80 @@ | ||
import Tracetest from '@tracetest/cypress'; | ||
|
||
const TRACETEST_API_TOKEN = Cypress.env('TRACETEST_API_TOKEN') || ''; | ||
|
||
const tracetest = Tracetest(); | ||
|
||
const definition = ` | ||
type: Test | ||
spec: | ||
id: aW1wb3J0cyBhIHBva2Vtb24= | ||
name: imports a pokemon | ||
trigger: | ||
type: traceid | ||
traceid: | ||
id: \${var:TRACE_ID} | ||
specs: | ||
- selector: span[tracetest.span.type="http"] | ||
name: "All HTTP Spans: Status code is not 400" | ||
assertions: | ||
- attr:http.status_code != 400 | ||
- selector: span[tracetest.span.type="database"] | ||
name: "All Database Spans: Processing time is less than 100ms" | ||
assertions: | ||
- attr:tracetest.span.duration < 100ms | ||
outputs: | ||
- name: MY_OUTPUT | ||
selector: span[tracetest.span.type="general" name="Tracetest trigger"] | ||
value: attr:name | ||
- name: MY_OUTPUT_2 | ||
selector: span[tracetest.span.type="general" name="Tracetest trigger"] | ||
value: attr:name | ||
`; | ||
|
||
describe('Home', { defaultCommandTimeout: 60000 }, () => { | ||
before(done => { | ||
tracetest.configure(TRACETEST_API_TOKEN).then(() => done()); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.visit('/', { | ||
onBeforeLoad: win => tracetest.capture(win.document), | ||
}); | ||
}); | ||
|
||
afterEach(done => { | ||
const definition = Cypress.env('definition') || ''; | ||
tracetest.runTest(definition).then(() => done()); | ||
}); | ||
|
||
|
||
// uncomment to wait for trace tests to be done | ||
after(done => { | ||
tracetest.summary().then(() => done()); | ||
}); | ||
|
||
it('create a pokemon', () => { | ||
cy.get('[data-cy="create-pokemon-button"]').should('be.visible').click(); | ||
cy.get('[data-cy="create-pokemon-modal"]').should('be.visible'); | ||
cy.get('#name').type('Pikachu'); | ||
cy.get('#type').type('Electric'); | ||
cy.get('#imageUrl').type('https://oyster.ignimgs.com/mediawiki/apis.ign.com/pokemon-blue-version/8/89/Pikachu.jpg'); | ||
|
||
cy.get('button').contains('OK').click(); | ||
}); | ||
|
||
it('imports a pokemon', { env: { definition } }, () => { | ||
cy.get('[data-cy="import-pokemon-button"]').click(); | ||
cy.get('[data-cy="import-pokemon-form"]').should('be.visible'); | ||
|
||
cy.get('[id="id"]') | ||
.last() | ||
.type(Math.floor(Math.random() * 101).toString()); | ||
cy.get('button').contains('OK').click({ force: true }); | ||
}); | ||
|
||
it('deletes a pokemon (2)', () => { | ||
cy.get('[data-cy="pokemon-list"]').should('be.visible'); | ||
cy.get('[data-cy="pokemon-card"]').first().click().get('[data-cy="delete-pokemon-button"]').first().click(); | ||
}); | ||
}); |
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,25 @@ | ||
// *********************************************** | ||
// This example commands.js shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add('login', (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) |
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/e2e.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
Oops, something went wrong.