Skip to content

Commit

Permalink
Merge pull request #4 from hdescottes/feat/Implements_cypress
Browse files Browse the repository at this point in the history
Feat/implements cypress
  • Loading branch information
hdescottes authored Aug 6, 2023
2 parents b5e6ab6 + 1cf0826 commit 1429858
Show file tree
Hide file tree
Showing 14 changed files with 22,624 additions and 12,420 deletions.
35 changes: 25 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Cache Gradle packages
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
Expand All @@ -36,17 +36,32 @@ jobs:
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
- name: Use Node 16.x
uses: actions/setup-node@v1
- name: Use Node 18.x
uses: actions/setup-node@v3
with:
node-version: '16.x'
node-version: '18.x'
cache: npm
cache-dependency-path: app-ui/package-lock.json
- name: Install dependencies
run: npm install -D puppeteer karma-chrome-launcher --save-dev @babel/preset-typescript
working-directory: app-ui
- name: Build
run: npm run build
working-directory: app-ui
- name: Test
run: npm test --no-watch --no-progress --browsers=ChromeHeadlessCI
working-directory: app-ui
run: npm run test --no-watch --no-progress --browsers=ChromeHeadlessCI
working-directory: app-ui

cypress-run:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
# Install NPM dependencies, cache them correctly
# and run all Cypress tests
- name: Cypress run
uses: cypress-io/github-action@v5
with:
working-directory: app-ui
build: npm run build
start: npm start
16 changes: 0 additions & 16 deletions app-ui/.browserslistrc

This file was deleted.

6 changes: 3 additions & 3 deletions app-ui/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"cli": {
"cache": {
"enabled": false
}
},
"analytics": false
},
"projects": {
"angularclient": {
Expand Down Expand Up @@ -106,6 +107,5 @@
}
}
}
},
"defaultProject": "angularclient"
}
}
24 changes: 24 additions & 0 deletions app-ui/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineConfig } from "cypress";
import * as createBundler from "@bahmutov/cypress-esbuild-preprocessor";
import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor";
import createEsbuildPlugin from "@badeball/cypress-cucumber-preprocessor/esbuild";

export default defineConfig({
e2e: {
specPattern: "**/*.feature",
baseUrl: "http://localhost:4200",
async setupNodeEvents(
on: Cypress.PluginEvents,
config: Cypress.PluginConfigOptions
): Promise<Cypress.PluginConfigOptions> {
await addCucumberPreprocessorPlugin(on, config);
on(
"file:preprocessor",
createBundler({
plugins: [createEsbuildPlugin(config)],
})
);
return config;
},
},
});
5 changes: 5 additions & 0 deletions app-ui/cypress/fixtures/example.json
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"
}
5 changes: 5 additions & 0 deletions app-ui/cypress/integration/home.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Feature: Home App Page

Scenario:
  When The user visit home page
  Then The user see the title
9 changes: 9 additions & 0 deletions app-ui/cypress/integration/home/home.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { When, Then } from '@badeball/cypress-cucumber-preprocessor'

When('The user visit home page', () => {
cy.visit("/home")
})

Then('The user see the title', () => {
cy.get("h1").contains("Default page")
})
37 changes: 37 additions & 0 deletions app-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>
// }
// }
// }
20 changes: 20 additions & 0 deletions app-ui/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.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')
2 changes: 1 addition & 1 deletion app-ui/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { pathsToModuleNameMapper } = require('ts-jest/utils');
const { pathsToModuleNameMapper } = require('ts-jest');
const { compilerOptions } = require('./tsconfig');

module.exports = {
Expand Down
Loading

0 comments on commit 1429858

Please sign in to comment.