-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[minor] Jest test component support (#783)
* component archetype jest support * minor updates
- Loading branch information
Showing
7 changed files
with
74 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
3 changes: 3 additions & 0 deletions
3
packages/electrode-archetype-react-component-dev/config/jest/__mocks__/file-mock.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// __mocks__/fileMock.js | ||
|
||
module.exports = "test-file-stub"; |
5 changes: 5 additions & 0 deletions
5
packages/electrode-archetype-react-component-dev/config/jest/__mocks__/framework-mock.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const Enzyme = require("enzyme"); | ||
const EnzymeAdapter = require("enzyme-adapter-react-16"); | ||
|
||
// Setup enzyme's react adapter | ||
Enzyme.configure({ adapter: new EnzymeAdapter() }); |
34 changes: 34 additions & 0 deletions
34
packages/electrode-archetype-react-component-dev/config/jest/jest.config.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const Path = require("path"); | ||
const optionalRequire = require("optional-require")(require); | ||
|
||
const rootDir = process.cwd(); | ||
const devPkgPath = Path.join( | ||
rootDir, | ||
"node_modules", | ||
"electrode-archetype-react-component-dev" | ||
); | ||
const jestPath = Path.join(devPkgPath, "config", "jest"); | ||
const fileMock = Path.join(jestPath, "__mocks__", "file-mock.js"); | ||
const frameworkMock = Path.join(jestPath, "__mocks__", "framework-mock.js"); | ||
|
||
const archetypeOptions = optionalRequire(Path.resolve("archetype", "config"), { | ||
default: {} | ||
}); | ||
|
||
const jestDefaultConfig = { | ||
rootDir, | ||
moduleFileExtensions: ["js", "jsx"], | ||
moduleDirectories: ["node_modules", "src"], | ||
moduleNameMapper: { | ||
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": fileMock, | ||
"\\.(css|less)$": "identity-obj-proxy" | ||
}, | ||
setupTestFrameworkScriptFile: frameworkMock, | ||
modulePathIgnorePatterns: ["<rootDir>/test", "<rootDir>/lib"] | ||
}; | ||
|
||
module.exports = Object.assign( | ||
{}, | ||
jestDefaultConfig, | ||
archetypeOptions.jest | ||
); |
This file contains 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
This file contains 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
This file contains 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