Last active
September 9, 2018 18:53
-
-
Save michelalbers/c01978e4d5291bff9780f738576df9ce to your computer and use it in GitHub Desktop.
Testing a GraphQL Next.js App with TypeScript and Apollo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
setupFiles: ['<rootDir>/jest.setup.js'], | |
testPathIgnorePatterns: ['<rootDir>/.next/', '<rootDir>/node_modules/'], | |
transform: { | |
"^.+\\.tsx?$": "ts-jest", | |
}, | |
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", | |
collectCoverageFrom: [ | |
"**/*.{js,jsx,ts,tsx}", | |
"!**/_app.tsx", | |
"!**/_document.tsx", | |
"!**/node_modules/**", | |
"!**/.next/**", | |
"!**/coverage/**" | |
], | |
moduleFileExtensions: [ | |
"ts", | |
"tsx", | |
"js", | |
"jsx", | |
"json", | |
"node" | |
], | |
moduleNameMapper: { | |
"\\.(css|less)$": "<rootDir>/__mocks__/styleMock.ts", | |
}, | |
globals: { | |
"ts-jest": { | |
useBabelRc: true, | |
tsConfigFile: "tsconfig.jest.json" | |
} | |
}, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const enzyme = require('enzyme'); | |
const Adapter = require('enzyme-adapter-react-16'); | |
const config = require('./next.config'); | |
const nextConfig = require('next/config'); | |
enzyme.configure({ adapter: new Adapter() }); | |
nextConfig.setConfig({ | |
publicRuntimeConfig: { | |
IMAGE_SERVER_URL: 'http://images.foo.bar', | |
IMAGE_PROCESSOR_URL: 'https://processor.foo.bar', | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment