-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #204 from JohanBrorson/configurable-testsuite-prop…
…erties-dir feat: make the test suite properties path configurable
- Loading branch information
Showing
7 changed files
with
118 additions
and
7 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const path = require('path'); | ||
const getTestSuitePropertiesPath = require('../utils/getTestSuitePropertiesPath'); | ||
|
||
jest.mock('path', () => { | ||
return { | ||
...jest.requireActual('path'), | ||
join: (...paths) => { | ||
return paths.join('/'); | ||
}, | ||
resolve: (...paths) => { | ||
return `/absolute/${paths.join('/')}` | ||
} | ||
}; | ||
}); | ||
|
||
const options = { | ||
testSuitePropertiesFile: 'properties.js', | ||
testSuitePropertiesDirectory: '<rootDir>', | ||
}; | ||
|
||
describe('getTestSuitePropertiesPath', () => { | ||
it('should replace <rootDir> in test suite properties path', () => { | ||
const testSuitePropertiesPath = getTestSuitePropertiesPath( | ||
options, | ||
'path/to', | ||
); | ||
expect(testSuitePropertiesPath).toEqual('/absolute/path/to/properties.js'); | ||
}); | ||
|
||
it('should not replace <rootDir> in test suite properties path when rootDir is not set', () => { | ||
const testSuitePropertiesPath = getTestSuitePropertiesPath(options); | ||
expect(testSuitePropertiesPath).toEqual('/absolute/<rootDir>/properties.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const path = require('path'); | ||
const replaceRootDirInOutput = require('./getOptions').replaceRootDirInOutput; | ||
|
||
module.exports = (options, rootDir = null) => { | ||
const testSuitePropertiesPath = replaceRootDirInOutput( | ||
rootDir, | ||
path.join( | ||
options.testSuitePropertiesDirectory, | ||
options.testSuitePropertiesFile, | ||
), | ||
); | ||
|
||
return path.isAbsolute(testSuitePropertiesPath) | ||
? testSuitePropertiesPath | ||
: path.resolve(testSuitePropertiesPath); | ||
}; |