mirror of
https://github.com/theoludwig/theoludwig.git
synced 2024-12-08 00:44:30 +01:00
chore: remove jest -> cypress for unit tests
This commit is contained in:
parent
8bc1471cbb
commit
1f4aa54211
@ -1,16 +0,0 @@
|
|||||||
cypress.config.ts
|
|
||||||
node_modules
|
|
||||||
.vscode
|
|
||||||
.git
|
|
||||||
build
|
|
||||||
.next
|
|
||||||
coverage
|
|
||||||
node_modules
|
|
||||||
tmp
|
|
||||||
temp
|
|
||||||
.DS_Store
|
|
||||||
.lighthouseci
|
|
||||||
.vercel
|
|
||||||
public/workbox-*.js
|
|
||||||
public/sw.js
|
|
||||||
cypress
|
|
@ -6,8 +6,7 @@
|
|||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"node": true,
|
"node": true,
|
||||||
"browser": true,
|
"browser": true
|
||||||
"jest": true
|
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"prettier/prettier": "error",
|
"prettier/prettier": "error",
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -11,8 +11,7 @@ out
|
|||||||
# production
|
# production
|
||||||
build
|
build
|
||||||
dist
|
dist
|
||||||
public/*.html
|
public/curriculum-vitae
|
||||||
jsonresume-theme-custom/theme/index.html
|
|
||||||
# PWA
|
# PWA
|
||||||
public/workbox-*.js
|
public/workbox-*.js
|
||||||
public/sw.js
|
public/sw.js
|
||||||
|
@ -4,5 +4,5 @@
|
|||||||
"http://localhost:3000/blog",
|
"http://localhost:3000/blog",
|
||||||
"http://localhost:3000/blog/hello-world"
|
"http://localhost:3000/blog/hello-world"
|
||||||
],
|
],
|
||||||
"files": ["./public/curriculum-vitae.html"]
|
"files": ["./public/curriculum-vitae/index.html"]
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
{
|
{
|
||||||
"*": ["editorconfig-checker"],
|
"*": ["editorconfig-checker"],
|
||||||
"*.{js,jsx,ts,tsx}": [
|
"*.{js,jsx,ts,tsx}": ["prettier --write", "eslint --fix"],
|
||||||
"prettier --write",
|
|
||||||
"eslint --fix",
|
|
||||||
"jest --findRelatedTests"
|
|
||||||
],
|
|
||||||
"*.{css,scss,sass,json,jsonc,yml,yaml}": ["prettier --write"],
|
"*.{css,scss,sass,json,jsonc,yml,yaml}": ["prettier --write"],
|
||||||
"*.{md,mdx}": ["prettier --write", "markdownlint --dot --fix"]
|
"*.{md,mdx}": ["prettier --write", "markdownlint-cli2 --fix"]
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ export const Footer: React.FC<FooterProps> = (props) => {
|
|||||||
<p className='mt-1'>
|
<p className='mt-1'>
|
||||||
Version{' '}
|
Version{' '}
|
||||||
<a
|
<a
|
||||||
|
data-cy='version-link'
|
||||||
className='text-yellow hover:underline dark:text-yellow-dark'
|
className='text-yellow hover:underline dark:text-yellow-dark'
|
||||||
href={versionLink}
|
href={versionLink}
|
||||||
target='_blank'
|
target='_blank'
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
import { render } from '@testing-library/react'
|
|
||||||
|
|
||||||
import { Header } from '..'
|
|
||||||
|
|
||||||
describe('<Header />', () => {
|
|
||||||
it('should render', () => {
|
|
||||||
const { getByText } = render(<Header />)
|
|
||||||
expect(getByText('Divlo')).toBeInTheDocument()
|
|
||||||
})
|
|
||||||
})
|
|
@ -4,13 +4,7 @@ import Image from 'next/image'
|
|||||||
import { Language } from './Language'
|
import { Language } from './Language'
|
||||||
import { SwitchTheme } from './SwitchTheme'
|
import { SwitchTheme } from './SwitchTheme'
|
||||||
|
|
||||||
export interface HeaderProps {
|
export const Header: React.FC = () => {
|
||||||
showLanguage?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export const Header: React.FC<HeaderProps> = (props) => {
|
|
||||||
const { showLanguage = false } = props
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className='sticky top-0 z-50 flex w-full justify-between border-b-2 border-gray-600 bg-white px-6 py-2 dark:border-gray-400 dark:bg-black'>
|
<header className='sticky top-0 z-50 flex w-full justify-between border-b-2 border-gray-600 bg-white px-6 py-2 dark:border-gray-400 dark:bg-black'>
|
||||||
<Link href='/'>
|
<Link href='/'>
|
||||||
@ -40,7 +34,7 @@ export const Header: React.FC<HeaderProps> = (props) => {
|
|||||||
</a>
|
</a>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
{showLanguage && <Language />}
|
<Language />
|
||||||
<SwitchTheme />
|
<SwitchTheme />
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
import { render } from '@testing-library/react'
|
|
||||||
|
|
||||||
import { ErrorPage } from '../ErrorPage'
|
|
||||||
|
|
||||||
describe('<ErrorPage />', () => {
|
|
||||||
it('should render the message and statusCode', () => {
|
|
||||||
const messageContent = 'message content'
|
|
||||||
const statusCode = 404
|
|
||||||
const { getByText } = render(
|
|
||||||
<ErrorPage statusCode={statusCode} message={messageContent} />
|
|
||||||
)
|
|
||||||
expect(getByText(messageContent)).toBeInTheDocument()
|
|
||||||
expect(getByText(statusCode)).toBeInTheDocument()
|
|
||||||
})
|
|
||||||
})
|
|
@ -1,16 +0,0 @@
|
|||||||
import { render } from '@testing-library/react'
|
|
||||||
|
|
||||||
import { Footer } from '../Footer'
|
|
||||||
|
|
||||||
describe('<Footer />', () => {
|
|
||||||
it('should render with appropriate link tag version', () => {
|
|
||||||
const version = '1.0.0'
|
|
||||||
const { getByText } = render(<Footer version={version} />)
|
|
||||||
const versionLink = getByText(version) as HTMLAnchorElement
|
|
||||||
expect(getByText('Divlo')).toBeInTheDocument()
|
|
||||||
expect(versionLink).toBeInTheDocument()
|
|
||||||
expect(versionLink.href).toEqual(
|
|
||||||
`https://github.com/Divlo/Divlo/releases/tag/v${version}`
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
|
@ -3,9 +3,18 @@ import { defineConfig } from 'cypress'
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
fixturesFolder: false,
|
fixturesFolder: false,
|
||||||
video: false,
|
video: false,
|
||||||
|
downloadsFolder: undefined,
|
||||||
screenshotOnRunFailure: false,
|
screenshotOnRunFailure: false,
|
||||||
|
|
||||||
e2e: {
|
e2e: {
|
||||||
baseUrl: 'http://localhost:3000',
|
baseUrl: 'http://localhost:3000',
|
||||||
supportFile: false
|
supportFile: false
|
||||||
|
},
|
||||||
|
|
||||||
|
component: {
|
||||||
|
devServer: {
|
||||||
|
framework: 'next',
|
||||||
|
bundler: 'webpack'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
18
cypress/component/Footer.cy.tsx
Normal file
18
cypress/component/Footer.cy.tsx
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { Footer } from 'components/Footer'
|
||||||
|
|
||||||
|
describe('<Footer />', () => {
|
||||||
|
it('should render with appropriate link tag version', () => {
|
||||||
|
const version = '1.0.0'
|
||||||
|
cy.mount(<Footer version={version} />)
|
||||||
|
cy.contains('Divlo')
|
||||||
|
.get('[data-cy=version-link]')
|
||||||
|
.should('have.text', version)
|
||||||
|
.should(
|
||||||
|
'have.attr',
|
||||||
|
'href',
|
||||||
|
`https://github.com/Divlo/Divlo/releases/tag/v${version}`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
export {}
|
17
cypress/component/utils/getAge.cy.ts
Normal file
17
cypress/component/utils/getAge.cy.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { getAge } from '../../../utils/getAge'
|
||||||
|
|
||||||
|
describe('utils/getAge', () => {
|
||||||
|
it('should calculate the right age of a person', () => {
|
||||||
|
cy.clock(new Date('2018-03-20')).then(() => {
|
||||||
|
const birthDate = new Date('1980-02-20')
|
||||||
|
expect(getAge(birthDate)).equal(38)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should calculate the right age of a person (taking into account the months)', () => {
|
||||||
|
cy.clock(new Date('2018-03-20')).then(() => {
|
||||||
|
const birthDate = new Date('1980-07-20')
|
||||||
|
expect(getAge(birthDate)).equal(37)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
@ -56,3 +56,5 @@ describe('Common > Header', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export {}
|
||||||
|
@ -5,3 +5,5 @@ describe('Page /404', () => {
|
|||||||
cy.get('[data-cy=status-code]').contains('404')
|
cy.get('[data-cy=status-code]').contains('404')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export {}
|
||||||
|
@ -5,3 +5,5 @@ describe('Page /500', () => {
|
|||||||
cy.get('[data-cy=status-code]').contains('500')
|
cy.get('[data-cy=status-code]').contains('500')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export {}
|
||||||
|
@ -11,3 +11,5 @@ describe('Page /blog/[slug]', () => {
|
|||||||
cy.get('[data-cy=status-code]').contains('404')
|
cy.get('[data-cy=status-code]').contains('404')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export {}
|
||||||
|
@ -20,3 +20,5 @@ describe('Page /blog', () => {
|
|||||||
.should('eq', '/blog/hello-world')
|
.should('eq', '/blog/hello-world')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export {}
|
||||||
|
@ -17,3 +17,5 @@ describe('Page /', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export {}
|
||||||
|
1
cypress/fixtures/example.json
Normal file
1
cypress/fixtures/example.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{}
|
3
cypress/support/commands.ts
Normal file
3
cypress/support/commands.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
export {}
|
14
cypress/support/component-index.html
Normal file
14
cypress/support/component-index.html
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<!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>
|
||||||
|
<!-- Used by Next.js to inject CSS. -->
|
||||||
|
<div id="__next_css__DO_NOT_USE__"></div>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div data-cy-root></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
13
cypress/support/component.ts
Normal file
13
cypress/support/component.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { mount } from 'cypress/react'
|
||||||
|
|
||||||
|
import './commands'
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
namespace Cypress {
|
||||||
|
interface Chainable {
|
||||||
|
mount: typeof mount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Cypress.Commands.add('mount', mount)
|
@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "../tsconfig.json",
|
|
||||||
"compilerOptions": {
|
|
||||||
"noEmit": true,
|
|
||||||
"types": ["cypress"],
|
|
||||||
"isolatedModules": false
|
|
||||||
},
|
|
||||||
"include": ["../node_modules/cypress", "./**/*.ts"]
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
const nextJest = require('next/jest')
|
|
||||||
|
|
||||||
const createJestConfig = nextJest()
|
|
||||||
const customJestConfig = {
|
|
||||||
moduleDirectories: ['node_modules', './'],
|
|
||||||
modulePathIgnorePatterns: ['<rootDir>/cypress'],
|
|
||||||
testEnvironment: 'jsdom',
|
|
||||||
setupFilesAfterEnv: [
|
|
||||||
'@testing-library/jest-dom/extend-expect',
|
|
||||||
'@testing-library/react'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = createJestConfig(customJestConfig)
|
|
@ -1,28 +0,0 @@
|
|||||||
import fs from 'node:fs'
|
|
||||||
import { fileURLToPath } from 'node:url'
|
|
||||||
|
|
||||||
import ejs from 'ejs'
|
|
||||||
import date from 'date-and-time'
|
|
||||||
import { Parcel } from '@parcel/core'
|
|
||||||
|
|
||||||
export const render = async (resume) => {
|
|
||||||
const themeIndexURL = new URL('./theme/index.ejs', import.meta.url)
|
|
||||||
const themeBuildURL = new URL('./theme/index.html', import.meta.url)
|
|
||||||
const indexHTMLURL = new URL('./dist/index.html', import.meta.url)
|
|
||||||
const themeBuildPath = fileURLToPath(themeBuildURL)
|
|
||||||
const html = await ejs.renderFile(fileURLToPath(themeIndexURL), {
|
|
||||||
date,
|
|
||||||
locals: {
|
|
||||||
...resume
|
|
||||||
}
|
|
||||||
})
|
|
||||||
await fs.promises.writeFile(themeBuildURL, html, { encoding: 'utf-8' })
|
|
||||||
const bundler = new Parcel({
|
|
||||||
entries: themeBuildPath,
|
|
||||||
source: themeBuildPath,
|
|
||||||
mode: 'production',
|
|
||||||
defaultConfig: '@parcel/config-default'
|
|
||||||
})
|
|
||||||
await bundler.run()
|
|
||||||
return await fs.promises.readFile(indexHTMLURL, { encoding: 'utf-8' })
|
|
||||||
}
|
|
4297
package-lock.json
generated
4297
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@ -18,14 +18,14 @@
|
|||||||
"lint:commit": "commitlint",
|
"lint:commit": "commitlint",
|
||||||
"lint:editorconfig": "editorconfig-checker",
|
"lint:editorconfig": "editorconfig-checker",
|
||||||
"lint:markdown": "markdownlint-cli2",
|
"lint:markdown": "markdownlint-cli2",
|
||||||
"lint:typescript": "eslint \"**/*.{js,jsx,ts,tsx}\"",
|
"lint:typescript": "eslint \"**/*.{js,jsx,ts,tsx}\" --ignore-path \".gitignore\"",
|
||||||
"lint:prettier": "prettier \".\" --check --ignore-path \".gitignore\"",
|
"lint:prettier": "prettier \".\" --check --ignore-path \".gitignore\"",
|
||||||
"lint:staged": "lint-staged",
|
"lint:staged": "lint-staged",
|
||||||
"test:unit": "jest",
|
"test:unit": "cypress run --component",
|
||||||
"test:html-w3c-validator": "start-server-and-test \"start\" \"http://localhost:3000\" \"html-w3c-validator\"",
|
"test:html-w3c-validator": "start-server-and-test \"start\" \"http://localhost:3000\" \"html-w3c-validator\"",
|
||||||
"test:lighthouse": "lhci autorun",
|
"test:lighthouse": "lhci autorun",
|
||||||
"test:e2e": "start-server-and-test \"start\" \"http://localhost:3000\" \"cypress run\"",
|
"test:e2e": "start-server-and-test \"start\" \"http://localhost:3000\" \"cypress run\"",
|
||||||
"test:e2e:dev": "start-server-and-test \"dev\" \"http://localhost:3000\" \"cypress open\"",
|
"test:dev": "start-server-and-test \"dev\" \"http://localhost:3000\" \"cypress open\"",
|
||||||
"resume:build": "node ./jsonresume-theme-custom/scripts/build.js",
|
"resume:build": "node ./jsonresume-theme-custom/scripts/build.js",
|
||||||
"release": "semantic-release",
|
"release": "semantic-release",
|
||||||
"deploy": "vercel",
|
"deploy": "vercel",
|
||||||
@ -65,9 +65,6 @@
|
|||||||
"@saithodev/semantic-release-backmerge": "2.1.2",
|
"@saithodev/semantic-release-backmerge": "2.1.2",
|
||||||
"@semantic-release/git": "10.0.1",
|
"@semantic-release/git": "10.0.1",
|
||||||
"@tailwindcss/typography": "0.5.4",
|
"@tailwindcss/typography": "0.5.4",
|
||||||
"@testing-library/jest-dom": "5.16.4",
|
|
||||||
"@testing-library/react": "13.3.0",
|
|
||||||
"@types/jest": "27.5.0",
|
|
||||||
"@types/node": "18.6.2",
|
"@types/node": "18.6.2",
|
||||||
"@types/react": "18.0.15",
|
"@types/react": "18.0.15",
|
||||||
"@types/unist": "2.0.6",
|
"@types/unist": "2.0.6",
|
||||||
@ -85,7 +82,6 @@
|
|||||||
"eslint-plugin-unicorn": "43.0.2",
|
"eslint-plugin-unicorn": "43.0.2",
|
||||||
"html-w3c-validator": "1.2.0",
|
"html-w3c-validator": "1.2.0",
|
||||||
"husky": "8.0.1",
|
"husky": "8.0.1",
|
||||||
"jest": "27.5.1",
|
|
||||||
"jsonresume-theme-custom": "file:./jsonresume-theme-custom",
|
"jsonresume-theme-custom": "file:./jsonresume-theme-custom",
|
||||||
"lint-staged": "13.0.3",
|
"lint-staged": "13.0.3",
|
||||||
"markdownlint-cli2": "0.5.0",
|
"markdownlint-cli2": "0.5.0",
|
||||||
|
@ -16,7 +16,7 @@ const Error404: NextPage<Error404Props> = (props) => {
|
|||||||
<>
|
<>
|
||||||
<Head title='404 | Divlo' />
|
<Head title='404 | Divlo' />
|
||||||
|
|
||||||
<Header showLanguage />
|
<Header />
|
||||||
<main className='flex flex-col md:mx-auto md:max-w-4xl lg:max-w-7xl'>
|
<main className='flex flex-col md:mx-auto md:max-w-4xl lg:max-w-7xl'>
|
||||||
<ErrorPage statusCode={404} message={t('errors:not-found')} />
|
<ErrorPage statusCode={404} message={t('errors:not-found')} />
|
||||||
</main>
|
</main>
|
||||||
|
@ -16,7 +16,7 @@ const Error500: NextPage<Error500Props> = (props) => {
|
|||||||
<>
|
<>
|
||||||
<Head title='500 | Divlo' />
|
<Head title='500 | Divlo' />
|
||||||
|
|
||||||
<Header showLanguage />
|
<Header />
|
||||||
<main className='flex flex-col md:mx-auto md:max-w-4xl lg:max-w-7xl'>
|
<main className='flex flex-col md:mx-auto md:max-w-4xl lg:max-w-7xl'>
|
||||||
<ErrorPage statusCode={500} message={t('errors:server-error')} />
|
<ErrorPage statusCode={500} message={t('errors:server-error')} />
|
||||||
</main>
|
</main>
|
||||||
|
@ -23,7 +23,7 @@ const Home: NextPage<HomeProps> = (props) => {
|
|||||||
<>
|
<>
|
||||||
<Head />
|
<Head />
|
||||||
|
|
||||||
<Header showLanguage />
|
<Header />
|
||||||
<main className='flex flex-col md:mx-auto md:max-w-4xl lg:max-w-7xl'>
|
<main className='flex flex-col md:mx-auto md:max-w-4xl lg:max-w-7xl'>
|
||||||
<Section isMain id='about'>
|
<Section isMain id='about'>
|
||||||
<Profile />
|
<Profile />
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
"removeComments": true,
|
"removeComments": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"types": ["jest", "@testing-library/jest-dom", "@testing-library/react"],
|
"types": ["cypress"],
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
@ -20,13 +20,6 @@
|
|||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"incremental": true
|
"incremental": true
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": ["dist", ".next", "out", "next.config.js"],
|
||||||
"dist",
|
|
||||||
".next",
|
|
||||||
"out",
|
|
||||||
"next.config.js",
|
|
||||||
"cypress.config.ts",
|
|
||||||
"cypress"
|
|
||||||
],
|
|
||||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
|
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
|
||||||
}
|
}
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
import { getAge } from '../getAge'
|
|
||||||
|
|
||||||
describe('utils/getAge', () => {
|
|
||||||
it('should calculate the right age of a person', () => {
|
|
||||||
const birthDate = new Date('1980-02-20')
|
|
||||||
jest.useFakeTimers().setSystemTime(new Date('2018-03-20'))
|
|
||||||
expect(getAge(birthDate)).toBe(38)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should calculate the right age of a person (taking into account the months)', () => {
|
|
||||||
const birthDate = new Date('1980-07-20')
|
|
||||||
jest.useFakeTimers().setSystemTime(new Date('2018-03-20'))
|
|
||||||
expect(getAge(birthDate)).toBe(37)
|
|
||||||
})
|
|
||||||
})
|
|
Loading…
Reference in New Issue
Block a user