Skip to content

Commit

Permalink
Fix Jest tests that fail on Windows (#896)
Browse files Browse the repository at this point in the history
* Fix failing tests

* Suppress build output in build tests
  • Loading branch information
tom-auger authored and endiliey committed Aug 10, 2018
1 parent e27e18b commit 3f896c8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/__tests__/build-files.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let outputAssetsFiles = [];

function generateSite() {
shell.cd('website');
shell.exec('yarn build');
shell.exec('yarn build', {silent: true});
}

function clearBuildFolder() {
Expand Down
3 changes: 2 additions & 1 deletion lib/server/__tests__/docs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ describe('getFile', () => {
fs.existsSync = jest.fn().mockReturnValue(true);
fs.readFileSync = jest.fn().mockImplementation(file => {
const fakePath = file.replace(process.cwd().replace(/website$/, ''), '');
return fakeContent[fakePath];
const normalizedPath = fakePath.replace(/\\/g, '/');
return fakeContent[normalizedPath];
});

test('docs does not exist', () => {
Expand Down
4 changes: 3 additions & 1 deletion lib/server/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ function getSubDir(file, refDir) {
}

function getLanguage(file, refDir) {
const separator = escapeStringRegexp(path.sep);
const baseDir = escapeStringRegexp(path.basename(refDir));
const regexSubFolder = new RegExp(
`${escapeStringRegexp(path.basename(refDir))}/(.*?)/.*`
`${baseDir}${separator}(.*?)${separator}.*`
);
const match = regexSubFolder.exec(file);

Expand Down

0 comments on commit 3f896c8

Please sign in to comment.