Skip to content

Commit

Permalink
initialize cypress testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dangowans committed Nov 28, 2024
1 parent 63b18f6 commit 8618e27
Show file tree
Hide file tree
Showing 23 changed files with 1,588 additions and 197 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
73 changes: 73 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Coverage Testing

on: [workflow_dispatch, push, pull_request]

permissions: read-all

jobs:
Coverage:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [18, 20, 21]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }}

name: Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'npm'

- name: Install Application
run: |
npm ci
npm install -g c8 cypress@13
- name: Copy Test Config
run: cp ./data/config.testing.js ./data/config.js

- name: Code Climate (Before)
if: ${{ github.event_name != 'pull_request' && env.CC_TEST_REPORTER_ID != '' && matrix.node == 20 }}
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./codeclimate-test-reporter
chmod +x codeclimate-test-reporter
./codeclimate-test-reporter before-build
- name: Verify Cypress
run: cypress verify
env:
CYPRESS_VERIFY_TIMEOUT: 600000

- name: Run Coverage Testing
run: npm run coverage
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}

- name: Code Climate (After)
if: ${{ github.event_name != 'pull_request' && env.CC_TEST_REPORTER_ID != '' && matrix.node == 20 }}
run: |
./codeclimate-test-reporter after-build -t lcov --exit-code $?
- name: Codecov
if: ${{ github.event_name != 'pull_request' && env.CODECOV_TOKEN != '' && matrix.node == 20 }}
run: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov -t ${CODECOV_TOKEN}
- name: DeepSource
if: ${{ github.event_name != 'pull_request' && env.DEEPSOURCE_DSN != '' && matrix.node == 20 }}
run: |
# Install deepsource CLI
curl https://deepsource.io/cli | sh
# From the root directory, run the report coverage command
./bin/deepsource report --analyzer test-coverage --key javascript --value-file ./coverage/lcov.info
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.nyc_output/
bin/daemon/
coverage/
cypress/downloads/
cypress/screenshots/
cypress/videos/

node_modules/

Expand Down
2 changes: 2 additions & 0 deletions cypress.config.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const _default: Cypress.ConfigOptions<any>;
export default _default;
9 changes: 9 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from 'cypress';
export default defineConfig({
e2e: {
baseUrl: 'http://localhost:9191',
specPattern: 'cypress/e2e/**/*.cy.ts',
supportFile: false,
projectId: 'gb2jfr'
}
});
10 changes: 10 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from 'cypress'

export default defineConfig({
e2e: {
baseUrl: 'http://localhost:9191',
specPattern: 'cypress/e2e/**/*.cy.ts',
supportFile: false,
projectId: 'gb2jfr'
}
})
1 change: 1 addition & 0 deletions cypress/e2e/01-scanner/scanner.cy.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'cypress-axe';
12 changes: 12 additions & 0 deletions cypress/e2e/01-scanner/scanner.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'cypress-axe';
const scannerPath = '/apps/inventoryScanner';
describe('Inventory Scanner', () => {
beforeEach('Loads Page', () => {
cy.visit(scannerPath);
cy.location('pathname').should('equal', scannerPath);
});
it('Has no detectable accessibility issues', () => {
cy.injectAxe();
cy.checkA11y();
});
});
16 changes: 16 additions & 0 deletions cypress/e2e/01-scanner/scanner.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'cypress-axe'

const scannerPath = '/apps/inventoryScanner'

describe('Inventory Scanner', () => {
beforeEach('Loads Page', () => {
cy.visit(scannerPath)
cy.location('pathname').should('equal', scannerPath)
})


it('Has no detectable accessibility issues', () => {
cy.injectAxe()
cy.checkA11y()
})
})
3 changes: 3 additions & 0 deletions data/config.testing.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { Config } from '../types/configTypes.js';
export declare const config: Config;
export default config;
22 changes: 22 additions & 0 deletions data/config.testing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export const config = {
webServer: {
httpPort: 9191
},
fasterWeb: {
tenantOrBaseUrl: 'test-faster-tenant'
},
modules: {
inventoryScanner: {
isEnabled: true,
scannerIpAddressRegex: /:(192.168.100.54|192.168.124.\d+)$/,
workOrders: {
acceptWorkTech: true
},
items: {
acceptNotValidated: true,
itemNumberRegex: /^\d{2}-\d{4}-\d{5}$/
}
}
}
};
export default config;
25 changes: 25 additions & 0 deletions data/config.testing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { Config } from '../types/configTypes.js'

export const config: Config = {
webServer: {
httpPort: 9191
},
fasterWeb: {
tenantOrBaseUrl: 'test-faster-tenant'
},
modules: {
inventoryScanner: {
isEnabled: true,
scannerIpAddressRegex: /:(192.168.100.54|192.168.124.\d+)$/,
workOrders: {
acceptWorkTech: true
},
items: {
acceptNotValidated: true,
itemNumberRegex: /^\d{2}-\d{4}-\d{5}$/
}
}
}
}

export default config
3 changes: 1 addition & 2 deletions modules/inventoryScanner/types.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};
Loading

0 comments on commit 8618e27

Please sign in to comment.