mirror of
https://github.com/BreizhHardware/portfolio.git
synced 2026-01-18 16:37:22 +01:00
Add unite test
This commit is contained in:
23
.github/workflows/deploy-test.yml
vendored
23
.github/workflows/deploy-test.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: Test build for dependabot
|
||||
name: Deploy to server
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -7,9 +7,9 @@ on:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build-test:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
environment: test
|
||||
environment: production
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -22,11 +22,20 @@ jobs:
|
||||
with:
|
||||
node-version: '18'
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Install dependencies and build
|
||||
run: |
|
||||
npm ci
|
||||
|
||||
- name: Run build for production
|
||||
run: |
|
||||
npm run build
|
||||
|
||||
- name: Install http-server
|
||||
run: npm install --save-dev http-server
|
||||
|
||||
- name: Start HTTP server
|
||||
run: npx http-server ./dist -p 8080 &
|
||||
env:
|
||||
CI: true
|
||||
|
||||
- name: Run Cypress tests
|
||||
run: npm run test
|
||||
env:
|
||||
CYPRESS_baseUrl: http://localhost:8080
|
||||
13
.github/workflows/deploy.yml
vendored
13
.github/workflows/deploy.yml
vendored
@@ -27,6 +27,19 @@ jobs:
|
||||
npm ci
|
||||
npm run build
|
||||
|
||||
- name: Install http-server
|
||||
run: npm install --save-dev http-server
|
||||
|
||||
- name: Start HTTP server
|
||||
run: npx http-server ./dist -p 8080 &
|
||||
env:
|
||||
CI: true
|
||||
|
||||
- name: Run Cypress tests
|
||||
run: npm run test
|
||||
env:
|
||||
CYPRESS_baseUrl: http://localhost:8080
|
||||
|
||||
- name: Copy build directory to server
|
||||
uses: Dylan700/sftp-upload-action@v1.2.3
|
||||
with:
|
||||
|
||||
11
cypress.config.ts
Normal file
11
cypress.config.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { defineConfig } from "cypress";
|
||||
|
||||
export default defineConfig({
|
||||
e2e: {
|
||||
setupNodeEvents(on, config) {
|
||||
// implement node event listeners here
|
||||
},
|
||||
specPattern: 'cypress/integration/**/*.js',
|
||||
baseUrl: 'http://localhost:8080',
|
||||
},
|
||||
});
|
||||
5
cypress/fixtures/example.json
Normal file
5
cypress/fixtures/example.json
Normal file
@@ -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"
|
||||
}
|
||||
10
cypress/integration/app_spec.js
Normal file
10
cypress/integration/app_spec.js
Normal file
@@ -0,0 +1,10 @@
|
||||
describe('App Component', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/');
|
||||
});
|
||||
|
||||
it('renders the app and checks if CSS is loaded', () => {
|
||||
cy.get('[data-testid="root"]').should('exist');
|
||||
cy.get('[data-testid="root"]').should('have.class', 'min-h-screen py-10 px-3 sm:px-5 bg-gray-100 dark:bg-gray-900');
|
||||
});
|
||||
});
|
||||
37
cypress/support/commands.ts
Normal file
37
cypress/support/commands.ts
Normal file
@@ -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
cypress/support/component-index.html
Normal file
12
cypress/support/component-index.html
Normal file
@@ -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>
|
||||
39
cypress/support/component.ts
Normal file
39
cypress/support/component.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
// ***********************************************************
|
||||
// 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/react18'
|
||||
|
||||
// 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 />)
|
||||
20
cypress/support/e2e.ts
Normal file
20
cypress/support/e2e.ts
Normal file
@@ -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')
|
||||
1694
package-lock.json
generated
1694
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,7 @@
|
||||
"@testing-library/react": "^16.0.1",
|
||||
"@testing-library/user-event": "^14.5.2",
|
||||
"aos": "^2.3.4",
|
||||
"cypress": "^13.15.0",
|
||||
"i18next": "^23.15.1",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
@@ -22,7 +23,10 @@
|
||||
"start": "vite",
|
||||
"build": "npx tsc && vite build",
|
||||
"serve": "vite preview",
|
||||
"build:css": "tailwindcss build src/index.css -o src/output.css"
|
||||
"build:css": "tailwindcss build src/index.css -o src/output.css",
|
||||
"cypress:open": "cypress open",
|
||||
"cypress:run": "cypress run",
|
||||
"test": "cypress run"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
@@ -50,4 +54,4 @@
|
||||
"vite-plugin-svgr": "^4.2.0",
|
||||
"vite-tsconfig-paths": "^5.0.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import Menu from "./components/Menu.tsx";
|
||||
import data from "./assets/DATA.ts";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import i18n from './i18n.js';
|
||||
import {createRoot} from "react-dom/client";
|
||||
|
||||
function App() {
|
||||
const [theme, setTheme] = useState("light");
|
||||
@@ -63,6 +64,9 @@ function App() {
|
||||
);
|
||||
}
|
||||
|
||||
ReactDOM.render(<App />, document.getElementById('root'));
|
||||
const container = document.getElementById('root');
|
||||
const root = createRoot(container);
|
||||
root.render(<App />);
|
||||
// ReactDOM.render(<App />, document.getElementById('root'));
|
||||
|
||||
export default App;
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"target": "esnext",
|
||||
"module": "esnext",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
@@ -8,12 +9,13 @@
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "esnext",
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react"
|
||||
"jsx": "react-jsx",
|
||||
"baseUrl": "./src"
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
Reference in New Issue
Block a user