feat: improve component based tests approach (#5923)

- new mode that mounts the spec iframe instead of application iframe
This commit is contained in:
Dmitriy Kovalenko
2020-04-26 23:25:24 +03:00
committed by GitHub
parent 79379a96d2
commit 379a9e7008
52 changed files with 1587 additions and 506 deletions
+6
View File
@@ -0,0 +1,6 @@
// but globby supports multiple wildcard search patterns 👏
const globby = require('globby')
module.exports = {
globby,
}
+22 -8
View File
@@ -2,6 +2,7 @@ _ = require("lodash")
fs = require("fs-extra")
cp = require("child_process")
path = require("path")
# we wrap glob to handle EMFILE error
glob = require("glob")
Promise = require("bluebird")
retry = require("bluebird-retry")
@@ -12,6 +13,8 @@ R = require("ramda")
os = require("os")
prettyMs = require("pretty-ms")
pluralize = require('pluralize')
debug = require("debug")("cypress:binary")
externalUtils = require("./3rd-party")
fs = Promise.promisifyAll(fs)
glob = Promise.promisify(glob)
@@ -70,17 +73,28 @@ copyAllToDist = (distDir) ->
## and any specified in package.json files
Promise.resolve(fs.readJsonAsync(pathToPackageJson(pkg)))
.then (json) ->
## grab all the files
## grab all the files that match "files" wildcards
## but without all negated files ("!src/**/*.spec.js" for example)
## and default included paths
## and convert to relative paths
Promise.resolve(
DEFAULT_PATHS
DEFAULT_PATHS
.concat(json.files or [])
.concat(json.main or [])
.map (file) ->
path.join(pkg, file)
)
.map(copyRelativePathToDist, {concurrency: 1})
.then (pkgFileMasks) ->
debug("for pkg %s have the following file masks %o", pkg, pkgFileMasks)
globOptions = {
cwd: pkg, # search in the package folder
absolute: false # and return relative file paths
}
externalUtils.globby(pkgFileMasks, globOptions)
# we find paths like "src/main.js" wrt "packages/foo"
# now we need to get the file path wrt current working directory
# like "packages/foo/src/main.js" so when we copy
# into the dist folder we get "<dist?/packages/foo/src/main.js"
.map (foundFileRelativeToPackageFolder) ->
path.join(pkg, foundFileRelativeToPackageFolder)
.tap(debug)
.map(copyRelativePathToDist, {concurrency: 1})
## fs-extra concurrency tests (copyPackage / copyRelativePathToDist)
## 1/1 41688
@@ -100,7 +114,7 @@ copyAllToDist = (distDir) ->
glob("./packages/*")
.map(copyPackage, {concurrency: 1})
.then ->
console.log("Finished Copying", new Date() - started)
console.log("Finished Copying %dms", new Date() - started)
forceNpmInstall = (packagePath, packageToInstall) ->
console.log("Force installing %s", packageToInstall)