Skip to content

Commit

Permalink
chore: remove cleaning dependencies from test-runner
Browse files Browse the repository at this point in the history
It doesn't change much since the e2e projects are packages of the monorepo and most of their dependencies will be stored in node_modules directory at the root level.
  • Loading branch information
pmrotule committed Oct 13, 2021
1 parent 8eb2cee commit 4b0050a
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions e2e/test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ 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>`.
/**
* Can be run as
* - `yarn test:e2e 3.x` to run only the 3.x tests
* - `yarn test:e2e 3.x/<projects dir>` to run only the test of a specific project
*/
const args = process.argv.slice(2)

async function runTests() {
Expand All @@ -32,27 +33,12 @@ async function runTests() {
}

async function runTest(dir) {
if (!args.includes('--cache')) {
await remove(dir, 'node_modules')
await remove(dir, 'yarn.lock')
await installDependencies(dir)
}
logStep(dir, 'Running tests')
info(`(${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(' ')
Expand All @@ -70,10 +56,6 @@ function filterDirectories(directories) {
return filtered.length ? filtered : directories
}

function logStep(dir, msg) {
return info(`(${dir}) ${msg}`)
}

function success(msg) {
console.info(chalk.green(formatLog(msg)))
}
Expand Down

0 comments on commit 4b0050a

Please sign in to comment.