-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
153 additions
and
23 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
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
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,91 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
const { spawn } = require('child_process') | ||
const chalk = require('chalk') | ||
const rimraf = require('rimraf') | ||
|
||
// Can be run as `yarn test:e2e --cache` to forego reinstalling node_modules, or | ||
// `yarn test:e2e 3.x`, or `yarn test:e2e 3.x/<projects dir>`, or | ||
// `yarn test:e2e --cache 3.x/<projects dir>`. | ||
const args = process.argv.slice(2) | ||
|
||
async function runTests() { | ||
const versionDirectories = ['2.x', '3.x'] | ||
const filteredVersionDirectories = filterDirectories(versionDirectories) | ||
const absVersionDirectories = filteredVersionDirectories.map(dir => | ||
path.join(__dirname, dir) | ||
) | ||
|
||
for (const versionDirectory of absVersionDirectories) { | ||
const fixtureDirectories = fs | ||
.readdirSync(versionDirectory, { withFileTypes: true }) | ||
.filter(dirent => dirent.isDirectory()) | ||
.map(dirent => dirent.name) | ||
|
||
const filteredDirectories = filterDirectories(fixtureDirectories) | ||
const absFixtureDirectories = filteredDirectories.map( | ||
dir => `${versionDirectory}/${dir}` | ||
) | ||
|
||
for (const directory of absFixtureDirectories) await runTest(directory) | ||
} | ||
} | ||
|
||
async function runTest(dir) { | ||
if (!args.includes('--cache')) { | ||
await Promise.all([ | ||
remove(dir, 'node_modules'), | ||
remove(dir, 'yarn.lock'), | ||
installDependencies(dir) | ||
]) | ||
} | ||
logStep(dir, 'Running tests') | ||
await execute(dir, 'yarn test') | ||
|
||
success(`(${dir}) Complete`) | ||
} | ||
|
||
async function remove(dir, target) { | ||
logStep(dir, `Removing ${target}`) | ||
await new Promise(resolve => rimraf(`${dir}/${target}`, resolve)) | ||
} | ||
|
||
async function installDependencies(dir) { | ||
logStep(dir, 'Installing node_modules') | ||
await execute(dir, 'yarn install --silent') | ||
} | ||
|
||
async function execute(dir, command) { | ||
const exitCode = await new Promise((resolve, reject) => { | ||
const [cmd, ...args] = command.split(' ') | ||
const child = spawn(cmd, args, { cwd: dir, stdio: 'inherit' }) | ||
child.on('close', resolve) | ||
child.on('error', reject) | ||
}) | ||
if (exitCode !== 0) process.exit(exitCode) | ||
} | ||
|
||
function filterDirectories(directories) { | ||
const filtered = directories.filter(dir => | ||
args.some(arg => arg.includes(dir)) | ||
) | ||
return filtered.length ? filtered : directories | ||
} | ||
|
||
function logStep(dir, msg) { | ||
return info(`(${dir}) ${msg}`) | ||
} | ||
|
||
function success(msg) { | ||
console.info(chalk.green(formatLog(msg))) | ||
} | ||
|
||
function info(msg) { | ||
console.info(chalk.blueBright(formatLog(msg))) | ||
} | ||
|
||
function formatLog(msg) { | ||
return `\n[vue-jest]: ${msg}\n` | ||
} | ||
|
||
runTests() |
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