feat: Add Jenkins integration for testing with pre-push hook
- Configured Jenkins FreeStyle job to trigger on push - Added `npm install` and `npm test` steps in Jenkins build configuration - Updated pre-push hook script to trigger Jenkins job and wait for test results - Installed jest, @testing-library/react, and @testing-library/jest-dom as dev dependencies for testing This commit sets up automated testing in Jenkins before code is pushed to the remote repository, ensuring code quality and preventing broken builds.
This commit is contained in:
32
Jenkinsfile
vendored
Normal file
32
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
stage('Install Dependencies') {
|
||||
steps {
|
||||
// Installiere npm Abhängigkeiten
|
||||
sh 'npm install'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Run Tests') {
|
||||
steps {
|
||||
// Führt Ihre Tests aus
|
||||
sh 'npm test'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
// Archivieren Sie die Testberichte, wenn verfügbar
|
||||
junit '**/test-results.xml'
|
||||
}
|
||||
success {
|
||||
echo 'Die Tests wurden erfolgreich abgeschlossen!'
|
||||
}
|
||||
failure {
|
||||
echo 'Einige Tests sind fehlgeschlagen.'
|
||||
}
|
||||
}
|
||||
}
|
||||
8
__tests__/MapComponent.test.js
Normal file
8
__tests__/MapComponent.test.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// __tests__/MapComponent.test.js
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import MapComponent from "../components/MapComponent";
|
||||
|
||||
test("renders map component", () => {
|
||||
render(<MapComponent />);
|
||||
expect(screen.getByText("TALAS.Map")).toBeInTheDocument();
|
||||
});
|
||||
4
jest.config.j
Normal file
4
jest.config.j
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
testEnvironment: 'jsdom',
|
||||
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
|
||||
};
|
||||
1
jest.setup.js
Normal file
1
jest.setup.js
Normal file
@@ -0,0 +1 @@
|
||||
import "@testing-library/jest-dom";
|
||||
3825
package-lock.json
generated
3825
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -21,14 +21,18 @@
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"export": "next export"
|
||||
"export": "next export",
|
||||
"test": "jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@testing-library/jest-dom": "^6.4.6",
|
||||
"@testing-library/react": "^16.0.0",
|
||||
"@types/leaflet": "^1.9.12",
|
||||
"@types/leaflet-contextmenu": "^1.4.3",
|
||||
"@types/react": "^18.3.1",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"autoprefixer": "^10.4.19",
|
||||
"jest": "^29.7.0",
|
||||
"postcss": "^8.4.38",
|
||||
"prettier": "^3.2.5",
|
||||
"tailwindcss": "^3.4.3"
|
||||
|
||||
Reference in New Issue
Block a user