1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-22 17:23:22 +01:00

jest cleanup

This commit is contained in:
Matthias Kretschmann 2021-02-06 14:40:39 +01:00
parent 7507a4f3ad
commit 2569fc6218
Signed by: m
GPG Key ID: 606EEEF3C479A91F
22 changed files with 19 additions and 26 deletions

View File

@ -189,7 +189,7 @@ To run all tests, including all linting tests:
npm test
```
All test files live beside the respective component. Testing setup, fixtures, and mocks can be found in `./jest.config.js` and `./jest` folder.
Most test files live beside the respective component. Testing setup, fixtures, and mocks can be found in the `./tests/` folder.
### 🎈 Add a new project

View File

@ -1,5 +0,0 @@
const babelOptions = {
presets: ['babel-preset-gatsby']
}
module.exports = require('babel-jest').createTransformer(babelOptions)

View File

@ -14,8 +14,8 @@
"lint:css": "stylelint ./src/**/*.{css,scss}",
"lint": "npm run lint:js && npm run lint:css",
"format": "prettier --write 'src/**/*.{js,jsx,css,scss}'",
"test": "npm run lint && jest --coverage --silent",
"test:watch": "npm run lint && jest --coverage --watch",
"test": "npm run lint && jest --coverage --silent -c tests/jest.config.js",
"test:watch": "npm run lint && jest --coverage --watch -c tests/jest.config.js",
"deploy:s3": "./scripts/deploy-s3.sh",
"new": "babel-node ./scripts/new.js"
},

View File

@ -1,8 +1,8 @@
import React from 'react'
import { render, fireEvent, waitForElement } from '@testing-library/react'
import Vcard, { constructVcard, toDataURL, init } from './Vcard'
import meta from '../../../jest/__fixtures__/meta.json'
import resume from '../../../jest/__fixtures__/resume.json'
import meta from '../../../tests/__fixtures__/meta.json'
import resume from '../../../tests/__fixtures__/resume.json'
const metaMock = {
...meta.metaYaml,

View File

@ -1,7 +1,7 @@
import React from 'react'
import { render } from '@testing-library/react'
import LogoUnit from './LogoUnit'
import data from '../../../jest/__fixtures__/meta.json'
import data from '../../../tests/__fixtures__/meta.json'
describe('LogoUnit', () => {
it('renders correctly from data file values', () => {

View File

@ -1,7 +1,7 @@
import React from 'react'
import { render } from '@testing-library/react'
import Repository from './Repository'
import repos from '../../../jest/__fixtures__/repos.json'
import repos from '../../../tests/__fixtures__/repos.json'
describe('Repository', () => {
it('renders correctly', () => {

View File

@ -1,7 +1,7 @@
import React from 'react'
import { render } from '@testing-library/react'
import Repositories from './Repositories'
import repos from '../../../jest/__fixtures__/repos.json'
import repos from '../../../tests/__fixtures__/repos.json'
describe('Repositories', () => {
it('renders correctly', () => {

View File

@ -1,8 +1,8 @@
import React from 'react'
import { render } from '@testing-library/react'
import Home from '../index'
import projects from '../../../jest/__fixtures__/projects.json'
import projectImageFiles from '../../../jest/__fixtures__/projectImageFiles.json'
import Home from '../src/pages/index'
import projects from './__fixtures__/projects.json'
import projectImageFiles from './__fixtures__/projectImageFiles.json'
describe('Home', () => {
const data = {

View File

@ -1,8 +1,8 @@
import React from 'react'
import { render } from '@testing-library/react'
import { createHistory, createMemorySource } from '@reach/router'
import Project from '../{ProjectsYaml.slug}'
import project from '../../../jest/__fixtures__/project.json'
import Project from '../src/pages/{ProjectsYaml.slug}'
import project from './__fixtures__/project.json'
describe('Project', () => {
const history = createHistory(createMemorySource('/oceanprotocol'))

View File

@ -1,12 +1,10 @@
module.exports = {
transform: {
'^.+\\.jsx?$': '<rootDir>/jest/jest-preprocess.js'
},
rootDir: '../',
moduleNameMapper: {
'.+\\.(css|styl|less|sass|scss)$': 'identity-obj-proxy',
'.+\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/jest/__mocks__/file-mock.js',
'\\.svg': '<rootDir>/jest/__mocks__/svgr-mock.js'
'<rootDir>/tests/__mocks__/file-mock.js',
'\\.svg': '<rootDir>/tests/__mocks__/svgr-mock.js'
},
testPathIgnorePatterns: [
'node_modules',
@ -18,6 +16,6 @@ module.exports = {
globals: {
__PATH_PREFIX__: ''
},
setupFiles: ['<rootDir>/jest/loadershim.js'],
setupFilesAfterEnv: ['<rootDir>/jest/setup-test-env.js']
setupFiles: ['<rootDir>/tests/loadershim.js'],
setupFilesAfterEnv: ['<rootDir>/tests/setup-test-env.js']
}

View File

@ -1,6 +1,6 @@
import React from 'react'
import { render } from '@testing-library/react'
import Resume from '../resume'
import Resume from '../src/pages/resume'
describe('Resume', () => {
it('renders correctly from data file values', () => {