add code coverage report
This commit is contained in:
		| @@ -2,6 +2,7 @@ image: node:latest | |||||||
|  |  | ||||||
| stages: | stages: | ||||||
|   - test |   - test | ||||||
|  |   - coverage | ||||||
|   - build |   - build | ||||||
|  |  | ||||||
| cache: | cache: | ||||||
| @@ -14,6 +15,14 @@ test: | |||||||
|     - npm install |     - npm install | ||||||
|     - npm run test |     - npm run test | ||||||
|  |  | ||||||
|  | coverage: | ||||||
|  |   stage: coverage | ||||||
|  |   script: | ||||||
|  |     - npm run coverage | ||||||
|  |   artifacts: | ||||||
|  |     reports: | ||||||
|  |       cobertura: coverage/cobertura-coverage.xml | ||||||
|  |  | ||||||
| build: | build: | ||||||
|   stage: build |   stage: build | ||||||
|   script: |   script: | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| { | { | ||||||
|   "name": "untitled", |   "name": "openmediacenter", | ||||||
|   "version": "0.1.0", |   "version": "0.1.0", | ||||||
|   "private": true, |   "private": true, | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
| @@ -17,8 +17,15 @@ | |||||||
|     "start": "react-scripts start", |     "start": "react-scripts start", | ||||||
|     "build": "react-scripts build", |     "build": "react-scripts build", | ||||||
|     "test": "react-scripts test", |     "test": "react-scripts test", | ||||||
|  |     "coverage": "react-scripts test --coverage --watchAll=false", | ||||||
|     "eject": "react-scripts eject" |     "eject": "react-scripts eject" | ||||||
|   }, |   }, | ||||||
|  |   "jest": { | ||||||
|  |     "collectCoverageFrom": [ | ||||||
|  |       "src/**/*.{js,jsx,ts,tsx}" | ||||||
|  |     ], | ||||||
|  |     "coverageReporters": ["cobertura","text"] | ||||||
|  |   }, | ||||||
|   "proxy": "http://192.168.0.248", |   "proxy": "http://192.168.0.248", | ||||||
|   "homepage": "/", |   "homepage": "/", | ||||||
|   "eslintConfig": { |   "eslintConfig": { | ||||||
|   | |||||||
							
								
								
									
										28
									
								
								src/App.test.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/App.test.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | |||||||
|  | import React from 'react'; | ||||||
|  | import { render } from '@testing-library/react'; | ||||||
|  | import App from './App'; | ||||||
|  | import ReactDom from "react-dom"; | ||||||
|  |  | ||||||
|  | describe('<App/>', function () { | ||||||
|  |   it('renders without crashing ', function () { | ||||||
|  |     const div = document.createElement("div"); | ||||||
|  |     ReactDom.render(<App/>,div); | ||||||
|  |     ReactDom.unmountComponentAtNode(div); | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   it('renders title', () => { | ||||||
|  |     const { getByText } = render(<App />); | ||||||
|  |     const linkElement = getByText(/Home Page/i); | ||||||
|  |     expect(linkElement).toBeInTheDocument(); | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   it('are navlinks correct', function () { | ||||||
|  |     const { getByText } = render(<App />); | ||||||
|  |     const randomElement = getByText(/Random Video/i); | ||||||
|  |     const categoryElement = getByText(/Categories/i); | ||||||
|  |     const settingsElement = getByText(/Settings/i); | ||||||
|  |     expect(randomElement).toBeInTheDocument(); | ||||||
|  |     expect(categoryElement).toBeInTheDocument(); | ||||||
|  |     expect(settingsElement).toBeInTheDocument(); | ||||||
|  |   }); | ||||||
|  | }); | ||||||
| @@ -1,16 +1,19 @@ | |||||||
| import React from "react"; | import React from "react"; | ||||||
| import ReactDom from 'react-dom' | import ReactDom from 'react-dom' | ||||||
| import Tag from './Tag' | import Tag from './Tag' | ||||||
|  |  | ||||||
| import {render} from '@testing-library/react' | import {render} from '@testing-library/react' | ||||||
| import "@testing-library/jest-dom" | import "@testing-library/jest-dom" | ||||||
|  |  | ||||||
| it('renders without crashing ', function () { | describe('<Tag/>', function () { | ||||||
|  |     it('renders without crashing ', function () { | ||||||
|         const div = document.createElement("div"); |         const div = document.createElement("div"); | ||||||
|         ReactDom.render(<Tag/>,div); |         ReactDom.render(<Tag/>,div); | ||||||
|         ReactDom.unmountComponentAtNode(div); |         ReactDom.unmountComponentAtNode(div); | ||||||
| }); |     }); | ||||||
|  |  | ||||||
| it('renders childs correctly', function () { |     it('renders childs correctly', function () { | ||||||
|         const {getByTestId} = render(<Tag>test</Tag>); |         const {getByTestId} = render(<Tag>test</Tag>); | ||||||
|         expect(getByTestId("Test-Tag")).toHaveTextContent("test"); |         expect(getByTestId("Test-Tag")).toHaveTextContent("test"); | ||||||
|  |     }); | ||||||
| }); | }); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user