Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions site/__mocks__/documentation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module.exports = [
{
id: '2a252835-849d-5e11-9b71-a4a18defc55b',
excerpt:
'Quick Start Install the latest version of Node.js, clone this repo and then:\n\nTo create a build locally:\n\nConfiguration\n\nThis static site…',
frontmatter: {
title: 'Development',
},
internal: {
contentFilePath:
'/Users/mimiflynn/Projects/MS/ms-gh-pages/site/content/documentation/intro-doc.mdx',
},
fields: {
slug: '/documentation/intro-doc/',
},
},
{
id: '9cbc3eec-d3ce-522a-b2fd-197c8407b252',
excerpt:
'This static site generator processes MDX in addition to traditional Markdown files. allows for the use of JSX components within Markdown.…',
frontmatter: {
title: 'Components 2.0',
},
internal: {
contentFilePath:
'/Users/mimiflynn/Projects/MS/ms-gh-pages/site/content/documentation/2.0/components.mdx',
},
fields: {
slug: '/documentation/2.0/components/',
},
},
{
id: '41748935-af24-51c3-8d32-458375e4246c',
excerpt:
'This static site generator processes MDX in addition to traditional Markdown files. allows for the use of JSX components within Markdown.…',
frontmatter: {
title: 'Components',
},
internal: {
contentFilePath:
'/Users/mimiflynn/Projects/MS/ms-gh-pages/site/content/documentation/1.0/components.mdx',
},
fields: {
slug: '/documentation/1.0/components/',
},
},
];
3 changes: 3 additions & 0 deletions site/__mocks__/file-mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// https://www.gatsbyjs.com/docs/how-to/testing/unit-testing/

module.exports = 'test-file-stub';
34 changes: 34 additions & 0 deletions site/__mocks__/gatsby.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// https://www.gatsbyjs.com/docs/how-to/testing/unit-testing/

const React = require('react');
const gatsby = jest.requireActual('gatsby');

module.exports = {
...gatsby,
graphql: jest.fn(),
Link: jest.fn().mockImplementation(
// these props are invalid for an `a` tag
({
activeClassName,
activeStyle,
getProps,
innerRef,
partiallyActive,
ref,
replace,
to,
...rest
}) =>
React.createElement('a', {
...rest,
href: to,
})
),
Slice: jest.fn().mockImplementation(({ alias, ...rest }) =>
React.createElement('div', {
...rest,
'data-test-slice-alias': alias,
})
),
useStaticQuery: jest.fn(),
};
24 changes: 24 additions & 0 deletions site/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// https://www.gatsbyjs.com/docs/how-to/testing/unit-testing/

module.exports = {
transform: {
'^.+\\.jsx?$': `<rootDir>/tests/jest-preprocess.js`,
},
moduleNameMapper: {
'.+\\.(css|styl|less|sass|scss)$': `identity-obj-proxy`,
'.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': `<rootDir>/__mocks__/file-mock.js`,
},
testPathIgnorePatterns: [`node_modules`, `\\.cache`, `<rootDir>.*/public`],
transformIgnorePatterns: [
`node_modules/(?!(gatsby|gatsby-script|gatsby-link)/)`,
],
globals: {
__PATH_PREFIX__: ``,
},
testEnvironmentOptions: {
url: `http://localhost`,
},
setupFiles: [`<rootDir>/tests/loadershim.js`],
testEnvironment: `jsdom`,
setupFilesAfterEnv: ['<rootDir>/tests/setup-test-env.js'],
};
Loading