Skip to content

Commit

Permalink
[FSK-16]: Configure Cypress (#13)
Browse files Browse the repository at this point in the history
This PR adds cypress configuration.
  • Loading branch information
erfan-goodarzi authored Sep 9, 2022
1 parent 95b2e71 commit cb2a050
Show file tree
Hide file tree
Showing 14 changed files with 6,954 additions and 9,831 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,27 @@ jobs:
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
exitZeroOnChanges: true # NOTE: Option to prevent the workflow from failing

cypress-run:
concurrency: ci-${{ github.ref }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run E2E tests
uses: cypress-io/github-action@v4
with:
record: true
parallel: true
start: npm run dev
build: npm run build
wait-on: "http://127.0.0.1:5173"

- name: Run Component tests
uses: cypress-io/github-action@v4
with:
install: false
component: true
start: npm run dev
build: npm run build
wait-on: "http://127.0.0.1:5173"
52 changes: 28 additions & 24 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# Cypress
cypress/videos
cypress/screenshots
9 changes: 5 additions & 4 deletions configs/cspell/charity.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
chromaui
dpxh
fullstacksjs
tanstack
jsdom
Mantine
stylis
tanstack
typecheck
vite
vitest
typecheck
chromaui
jsdom
14 changes: 14 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig } from 'cypress';

export default defineConfig({
e2e: {
baseUrl: 'http://127.0.0.1:5173',
projectId: 'dpxh3q',
},
component: {
devServer: {
framework: 'react',
bundler: 'vite',
},
},
});
9 changes: 9 additions & 0 deletions cypress/component/App.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';

import { App } from '../../src/App';

describe('<App>', () => {
it('playground', () => {
cy.mount(<App />);
});
});
5 changes: 5 additions & 0 deletions cypress/e2e/smoke.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('e2e smoke test', () => {
it('should visit', () => {
cy.visit('/');
});
});
9 changes: 9 additions & 0 deletions cypress/e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"projectId": "dpxh3q",
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "node"]
},
"include": ["**/*.ts"]
}
5 changes: 5 additions & 0 deletions 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": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
1 change: 1 addition & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/cypress/add-commands';
12 changes: 12 additions & 0 deletions 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>
35 changes: 35 additions & 0 deletions cypress/support/component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// ***********************************************************
// 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';

// Augment the Cypress namespace to include type definitions for
// your custom command.
// Alternatively you can use CommonJS syntax:
// require('./commands')
import { mount } from 'cypress/react18';
// Alternatively, can be defined in cypress/support/component.d.ts
// with a <reference path="./component" /> at the top of your spec.
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Cypress {
interface Chainable {
mount: typeof mount;
}
}
}

Cypress.Commands.add('mount', mount);
20 changes: 20 additions & 0 deletions 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')
Loading

0 comments on commit cb2a050

Please sign in to comment.