-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #29637 - Updating to dynamically find path
- Loading branch information
John Mitsch
committed
Apr 30, 2020
1 parent
c87a143
commit 45d8987
Showing
3 changed files
with
51 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,64 @@ | ||
const path = require('path') | ||
//const foremanReact = path.join(__dirname, "../foreman/webpack/assets/javascripts/react_app") | ||
const foremanReact = "/home/jenkins/workspace/katello-pr-test/foreman/webpack/assets/javascripts/react_app" | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
// Check for foremanReact files provided by Foreman and make available as module in Jest. | ||
const checkForForemanReact = (foremanLocations, foremanReact) => { | ||
const currentDir = process.cwd(); | ||
|
||
let foremanReactFullPath; | ||
foremanLocations.forEach((relativeForemanPath) => { | ||
if (fs.existsSync(path.join(currentDir, relativeForemanPath))) { | ||
const fullPath = path.join(currentDir, relativeForemanPath, foremanReact); | ||
if (fs.existsSync(fullPath)) foremanReactFullPath = fullPath; | ||
} | ||
}); | ||
return foremanReactFullPath; | ||
}; | ||
|
||
const foremanReactRelative = 'webpack/assets/javascripts/react_app'; | ||
const possibleForemanLocations = ['./foreman', '../foreman', '../../foreman']; | ||
const notFound = 'Foreman directory can not be found! These tests require Foreman to be present ' + | ||
'in either a parent, sibling, or child directory relative to Katello and contain the expected ' + | ||
`files in ./${foremanReactRelative}, relative to the Foreman directory.`; | ||
|
||
const foremanReactFull = checkForForemanReact(possibleForemanLocations, foremanReactRelative); | ||
if (!foremanReactFull) throw new Error(notFound); | ||
|
||
// Jest configuration | ||
module.exports = { | ||
collectCoverage: true, | ||
collectCoverageFrom: [ | ||
"webpack/**/*.js", | ||
"!webpack/**/bundle*" | ||
'webpack/**/*.js', | ||
'!webpack/**/bundle*', | ||
], | ||
coverageReporters: [ | ||
"lcov" | ||
'lcov', | ||
], | ||
testURL: "http://localhost/", | ||
testURL: 'http://localhost/', | ||
setupFiles: [ | ||
"raf/polyfill", | ||
"./webpack/test_setup.js" | ||
'raf/polyfill', | ||
'./webpack/test_setup.js', | ||
], | ||
setupFilesAfterEnv: [ | ||
"./webpack/global_test_setup.js" | ||
'./webpack/global_test_setup.js', | ||
], | ||
testPathIgnorePatterns: [ | ||
"/node_modules/", | ||
"<rootDir>/foreman/", | ||
"<rootDir>/.+fixtures.+", | ||
"<rootDir>/engines" | ||
'/node_modules/', | ||
'<rootDir>/foreman/', | ||
'<rootDir>/.+fixtures.+', | ||
'<rootDir>/engines', | ||
], | ||
moduleDirectories: [ | ||
"node_modules/@theforeman/vendor-core/node_modules", | ||
"node_modules", | ||
"webpack/test-utils" | ||
'node_modules/@theforeman/vendor-core/node_modules', | ||
'node_modules', | ||
'webpack/test-utils', | ||
], | ||
modulePathIgnorePatterns: [ | ||
'<rootDir>/foreman/', | ||
], | ||
moduleNameMapper: { | ||
"^.+\\.(css|scss)$": "identity-obj-proxy", | ||
"foremanReact(.*)$": `${foremanReact}$1` | ||
} | ||
} | ||
'^.+\\.(css|scss)$': 'identity-obj-proxy', | ||
'^foremanReact(.*)$': `${foremanReactFull}$1`, | ||
}, | ||
}; | ||
|
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 @@ | ||
export const addLocaleData = jest.fn(); | ||
export const FormattedRelative = jest.fn(); | ||
export const intlShape = jest.fn(); |
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 @@ | ||
export default {}; |