Skip to content

Commit

Permalink
Setup cypress testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ccremer committed Sep 13, 2022
1 parent 36c9296 commit 9dfe608
Show file tree
Hide file tree
Showing 10 changed files with 3,621 additions and 16 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- docs/**

jobs:
integration:
go:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -38,3 +38,17 @@ jobs:
with:
coverageLocations: cover.out:gocov
prefix: github.com/${{ github.repository }}

cypress:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
cache-dependency-path: ui/package-lock.json

- name: Run tests
run: make test-ui
3 changes: 3 additions & 0 deletions ui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ dist-ssr
*.njsproj
*.sln
*.sw?

# Cypress
cypress/videos/
5 changes: 3 additions & 2 deletions ui/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ lint-ui: ui/node_modules ## Runs linters for the UI code
$(npm_run) lint
$(npm_run) check

.npm-install:
$(npm) install
.PHONY: test-ui
test-ui: ui/node_modules ## Runs tests for the UI code
$(npm_run) cy:run
10 changes: 10 additions & 0 deletions ui/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from "cypress";

export default defineConfig({
component: {
devServer: {
framework: "svelte",
bundler: "vite",
},
},
});
37 changes: 37 additions & 0 deletions ui/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts 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) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
12 changes: 12 additions & 0 deletions ui/cypress/support/component-index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Components App</title>
</head>
<body>
<div data-cy-root></div>
</body>
</html>
41 changes: 41 additions & 0 deletions ui/cypress/support/component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// ***********************************************************
// This example support/component.ts 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')

import { mount } from 'cypress/svelte'

import 'bootstrap/dist/css/bootstrap.min.css'

// Augment the Cypress namespace to include type definitions for
// your custom command.
// Alternatively, can be defined in cypress/support/component.d.ts
// with a <reference path="./component" /> at the top of your spec.
declare global {
namespace Cypress {
interface Chainable {
mount: typeof mount
}
}
}

Cypress.Commands.add('mount', mount)

// Example use:
// cy.mount(MyComponent)
Loading

0 comments on commit 9dfe608

Please sign in to comment.