Skip to content

Instantly share code, notes, and snippets.

@michelalbers
Last active September 9, 2018 18:53
Show Gist options
  • Save michelalbers/c01978e4d5291bff9780f738576df9ce to your computer and use it in GitHub Desktop.
Save michelalbers/c01978e4d5291bff9780f738576df9ce to your computer and use it in GitHub Desktop.
Testing a GraphQL Next.js App with TypeScript and Apollo
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"
}
},
}
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