Skip to content

Commit

Permalink
normalize icons across OSes in integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed May 27, 2018
1 parent 2163e61 commit 1b98ec1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
22 changes: 12 additions & 10 deletions integration-tests/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,6 @@ const linkJestPackage = (packageName: string, cwd: Path) => {
fs.symlinkSync(packagePath, destination, 'dir');
};

const fileExists = (filePath: Path) => {
try {
fs.accessSync(filePath, fs.F_OK);
return true;
} catch (e) {
return false;
}
};

const makeTemplate = (str: string): ((values?: Array<any>) => string) => {
return (values: ?Array<any>) => {
return str.replace(/\$(\d+)/g, (match, number) => {
Expand Down Expand Up @@ -175,14 +166,25 @@ const cleanupStackTrace = (output: string) => {
.replace(/^.*at.*[\s][\(]?(\S*\:\d*\:\d*).*$/gm, ' at $1');
};

const normalizeIcons = (str: string) => {
if (!str) {
return str;
}

// Make sure to keep in sync with `jest-cli/src/constants`
return str
.replace(new RegExp('\u00D7', 'g'), '\u2715')
.replace(new RegExp('\u221A', 'g'), '\u2713');
};

module.exports = {
cleanup,
copyDir,
createEmptyPackage,
extractSummary,
fileExists,
linkJestPackage,
makeTemplate,
normalizeIcons,
run,
writeFiles,
};
13 changes: 10 additions & 3 deletions integration-tests/runJest.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
'use strict';

const path = require('path');
const fs = require('fs');
const execa = require('execa');
const {Writable} = require('readable-stream');
const {fileExists} = require('./Utils');
const {normalizeIcons} = require('./Utils');

const {sync: spawnSync} = execa;

Expand All @@ -37,7 +38,7 @@ function runJest(
}

const localPackageJson = path.resolve(dir, 'package.json');
if (!options.skipPkgJsonCheck && !fileExists(localPackageJson)) {
if (!options.skipPkgJsonCheck && !fs.existsSync(localPackageJson)) {
throw new Error(
`
Make sure you have a local package.json file at
Expand All @@ -63,6 +64,9 @@ function runJest(
// For compat with cross-spawn
result.status = result.code;

result.stdout = normalizeIcons(result.stdout);
result.stderr = normalizeIcons(result.stderr);

return result;
}

Expand Down Expand Up @@ -102,7 +106,7 @@ runJest.until = async function(
}

const localPackageJson = path.resolve(dir, 'package.json');
if (!options.skipPkgJsonCheck && !fileExists(localPackageJson)) {
if (!options.skipPkgJsonCheck && !fs.existsSync(localPackageJson)) {
throw new Error(
`
Make sure you have a local package.json file at
Expand Down Expand Up @@ -145,6 +149,9 @@ runJest.until = async function(
// For compat with cross-spawn
result.status = result.code;

result.stdout = normalizeIcons(result.stdout);
result.stderr = normalizeIcons(result.stderr);

return result;
};

Expand Down
5 changes: 0 additions & 5 deletions scripts/SkipOnWindows.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@

const SkipOnWindows = {
suite() {
if (process.platform === 'win32') {
fit('does not work on Windows', () => {
console.warn('[SKIP] Does not work on Windows');
});
}
},
};

Expand Down

0 comments on commit 1b98ec1

Please sign in to comment.