mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-23 15:39:28 -05:00
try revert everything
03-0000003b
This commit is contained in:
+1
-2
@@ -1,2 +1 @@
|
||||
*.*
|
||||
!*.ts
|
||||
**/*
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
exports['packages can copy files from package.json 1'] = {
|
||||
"[cwd]": {
|
||||
"packages": {
|
||||
"coffee": {
|
||||
"package.json": "{\"main\":\"src/main.js\", \"name\": \"foo\", \"files\": [\"lib\"]}",
|
||||
"src": {
|
||||
"main.js": "console.log()"
|
||||
},
|
||||
"lib": {
|
||||
"foo.js": "{}"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tmp": {
|
||||
"packages": {
|
||||
"coffee": {
|
||||
"package.json": "{\"main\":\"src/main.js\", \"name\": \"foo\", \"files\": [\"lib\"]}",
|
||||
"src": {
|
||||
"main.js": "console.log()"
|
||||
},
|
||||
"lib": {
|
||||
"foo.js": "{}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports['transformRequires can find and replace symlink requires 1'] = {
|
||||
"[cwd]": {
|
||||
"build": {
|
||||
"linux": {
|
||||
"Cypress": {
|
||||
"resources": {
|
||||
"app": {
|
||||
"packages": {
|
||||
"foo": {
|
||||
"package.json": "{\"main\":\"src/main.js\", \"name\": \"foo\", \"files\": [\"lib\"]}",
|
||||
"src": {
|
||||
"main.js": "console.log()"
|
||||
},
|
||||
"lib": {
|
||||
"foo.js": "require(\"../../bar/src/main\")"
|
||||
}
|
||||
},
|
||||
"bar": {
|
||||
"package.json": "{\"main\":\"src/main.js\", \"name\": \"foo\", \"files\": [\"lib\"]}",
|
||||
"src": {
|
||||
"main.js": "console.log()"
|
||||
},
|
||||
"lib": {
|
||||
"foo.js": "require(\"../../foo/lib/somefoo\")"
|
||||
},
|
||||
"node_modules": {
|
||||
"no-search.js": ""
|
||||
},
|
||||
"dist": {
|
||||
"no-search.js": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tmp": {}
|
||||
}
|
||||
|
||||
exports['transformRequires can find and replace symlink requires on win32 1'] = {
|
||||
"[cwd]": {
|
||||
"build": {
|
||||
"linux": {
|
||||
"Cypress": {
|
||||
"resources": {
|
||||
"app": {
|
||||
"packages": {
|
||||
"foo": {
|
||||
"package.json": "{\"main\":\"src/main.js\", \"name\": \"foo\", \"files\": [\"lib\"]}",
|
||||
"src": {
|
||||
"main.js": "console.log()"
|
||||
},
|
||||
"lib": {
|
||||
"foo.js": "require(\"../../bar/src/main\")"
|
||||
}
|
||||
},
|
||||
"bar": {
|
||||
"package.json": "{\"main\":\"src/main.js\", \"name\": \"foo\", \"files\": [\"lib\"]}",
|
||||
"src": {
|
||||
"main.js": "console.log()"
|
||||
},
|
||||
"lib": {
|
||||
"foo.js": "require(\"../../foo/lib/somefoo\")"
|
||||
},
|
||||
"node_modules": {
|
||||
"no-search.js": ""
|
||||
},
|
||||
"dist": {
|
||||
"no-search.js": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tmp": {}
|
||||
}
|
||||
+1
-5
@@ -54,7 +54,6 @@
|
||||
"move-binaries": "node ./scripts/binary.js move-binaries",
|
||||
"binary-release": "node ./scripts/binary.js release",
|
||||
"test-scripts": "mocha -r packages/coffee/register -r packages/ts/register --reporter spec 'scripts/unit/**/*spec.js'",
|
||||
"test-scripts-watch": "npm run test-scripts -- --watch --watch-extensions 'ts,js,coffee'",
|
||||
"test-s3-api": "node -r ./packages/coffee/register -r ./packages/ts/register scripts/binary/s3-api-demo.ts",
|
||||
"test-mocha": "mocha --reporter spec scripts/spec.js",
|
||||
"test-mocha-snapshot": "mocha scripts/mocha-snapshot-spec.js",
|
||||
@@ -79,7 +78,6 @@
|
||||
"@types/debug": "4.1.4",
|
||||
"@types/execa": "0.7.2",
|
||||
"@types/fs-extra": "3.0.0",
|
||||
"@types/glob": "^7.1.1",
|
||||
"@types/lodash": "4.14.122",
|
||||
"@types/mocha": "2.2.48",
|
||||
"@types/node": "11.12.0",
|
||||
@@ -111,7 +109,7 @@
|
||||
"eslint-plugin-cypress-dev": "2.1.0",
|
||||
"eslint-plugin-mocha": "5.3.0",
|
||||
"eslint-plugin-react": "7.12.4",
|
||||
"execa": "^1.0.0",
|
||||
"execa": "1.0.0",
|
||||
"execa-wrap": "1.4.0",
|
||||
"filesize": "4.1.2",
|
||||
"find-package-json": "1.2.0",
|
||||
@@ -140,7 +138,6 @@
|
||||
"mocha-banner": "1.1.2",
|
||||
"mocha-junit-reporter": "1.18.0",
|
||||
"mocha-multi-reporters": "1.1.7",
|
||||
"mock-fs": "^4.9.0",
|
||||
"obfuscator": "0.5.4",
|
||||
"parse-github-repo-url": "1.4.1",
|
||||
"plist": "2.1.0",
|
||||
@@ -148,7 +145,6 @@
|
||||
"prefixed-list": "1.0.1",
|
||||
"pretty-ms": "5.0.0",
|
||||
"print-arch": "1.0.0",
|
||||
"proxyquire": "^2.1.0",
|
||||
"ramda": "0.24.1",
|
||||
"shelljs": "0.8.3",
|
||||
"sinon": "7.3.2",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"name": "@packages/coffee",
|
||||
"main": "index.js",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"coffee-script": "1.12.7"
|
||||
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
/// <reference path="../../cli/types/index.d.ts" />
|
||||
export const $Cypress: Cypress.Cypress
|
||||
export default $Cypress
|
||||
@@ -1 +1 @@
|
||||
module.exports = require('./src/main')
|
||||
module.exports = require("./lib/driver")
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
"name": "@packages/driver",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"main": "index.js",
|
||||
"browser": "src/main",
|
||||
"scripts": {
|
||||
"prestart": "npm run check-deps-pre",
|
||||
"start": "../coffee/node_modules/.bin/coffee test/support/server.coffee",
|
||||
|
||||
@@ -274,7 +274,7 @@ module.exports = (Commands, Cypress, cy, state, config) ->
|
||||
return false
|
||||
|
||||
onEvent: (id, key, column, which, value) ->
|
||||
updateTable.apply(window, arguments) if updateTable
|
||||
updateTable.apply(null, arguments) if updateTable
|
||||
|
||||
## fires only when the 'value'
|
||||
## of input/text/contenteditable
|
||||
|
||||
@@ -10,7 +10,7 @@ command = (ctx, name, args...) ->
|
||||
args: { name, cmds }
|
||||
})
|
||||
|
||||
ctx[name].apply(window, args)
|
||||
ctx[name].apply(null, args)
|
||||
|
||||
module.exports = (Commands, Cypress, cy, state, config) ->
|
||||
Commands.addChainer({
|
||||
@@ -22,5 +22,5 @@ module.exports = (Commands, Cypress, cy, state, config) ->
|
||||
command: (args...) ->
|
||||
args.unshift(cy)
|
||||
|
||||
command.apply(window, args)
|
||||
command.apply(null, args)
|
||||
})
|
||||
|
||||
@@ -62,7 +62,7 @@ module.exports = (Commands, Cypress, cy, state, config) ->
|
||||
args = arguments
|
||||
|
||||
cy.retry ->
|
||||
checkForXhr.apply(window, args)
|
||||
checkForXhr.apply(null, args)
|
||||
, options
|
||||
|
||||
waitForXhr = (str, options) ->
|
||||
@@ -173,13 +173,13 @@ module.exports = (Commands, Cypress, cy, state, config) ->
|
||||
try
|
||||
switch
|
||||
when _.isFinite(msOrFnOrAlias)
|
||||
waitNumber.apply(window, args)
|
||||
waitNumber.apply(null, args)
|
||||
when _.isFunction(msOrFnOrAlias)
|
||||
waitFunction()
|
||||
when _.isString(msOrFnOrAlias)
|
||||
waitString.apply(window, args)
|
||||
waitString.apply(null, args)
|
||||
when _.isArray(msOrFnOrAlias) and not _.isEmpty(msOrFnOrAlias)
|
||||
waitString.apply(window, args)
|
||||
waitString.apply(null, args)
|
||||
else
|
||||
## figure out why this error failed
|
||||
arg = switch
|
||||
|
||||
@@ -160,8 +160,8 @@ class $Cypress
|
||||
## or parsed. we have not received any custom commands
|
||||
## at this point
|
||||
onSpecWindow: (specWindow) ->
|
||||
logFn = (args...) =>
|
||||
@log.apply(@, args)
|
||||
logFn = =>
|
||||
@log.apply(@, arguments)
|
||||
|
||||
## create cy and expose globally
|
||||
@cy = window.cy = $Cy.create(specWindow, @, @Cookies, @state, @config, logFn)
|
||||
|
||||
@@ -57,7 +57,7 @@ create = (specWindow, Cypress, Cookies, state, config, log) ->
|
||||
isStopped = -> stopped
|
||||
|
||||
onFinishAssertions = ->
|
||||
assertions.finishAssertions.apply(window, arguments)
|
||||
assertions.finishAssertions.apply(null, arguments)
|
||||
|
||||
warnMixingPromisesAndCommands = ->
|
||||
title = state("runnable").fullTitle()
|
||||
|
||||
@@ -290,7 +290,7 @@ overrideRunnerHook = (Cypress, _runner, getTestById, getTest, setTest, getTests)
|
||||
testAfterRun(test, Cypress)
|
||||
|
||||
## and now invoke next(err)
|
||||
originalFn.apply(window, arguments)
|
||||
originalFn.apply(null, arguments)
|
||||
|
||||
switch name
|
||||
when "afterEach"
|
||||
|
||||
@@ -418,7 +418,7 @@ create = (options = {}) ->
|
||||
return if isCalled
|
||||
isCalled = true
|
||||
try
|
||||
return fn.apply(window, arguments)
|
||||
return fn.apply(null, arguments)
|
||||
finally
|
||||
isCalled = false
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const $jquery = require('./jquery')
|
||||
|
||||
const docNode = window.Node.DOCUMENT_NODE
|
||||
const docNode = Node.DOCUMENT_NODE
|
||||
|
||||
const isDocument = (obj) => {
|
||||
try {
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"build-js": "bin-up tsc --project .",
|
||||
"test": "bin-up mocha --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json",
|
||||
"clean-deps": "rm -rf node_modules"
|
||||
"test": "bin-up mocha --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"bluebird": "3.5.3",
|
||||
|
||||
@@ -22,7 +22,7 @@ describe "aliases", ->
|
||||
|
||||
@runner = new EventEmitter()
|
||||
|
||||
cy.visit("/dist").then (win) =>
|
||||
cy.visit("cypress/support/index.html").then (win) =>
|
||||
win.render({
|
||||
runner: @runner
|
||||
specPath: "/foo/bar"
|
||||
|
||||
@@ -6,7 +6,7 @@ describe('controls', function () {
|
||||
|
||||
this.runner = new EventEmitter()
|
||||
|
||||
cy.visit('/dist').then((win) => {
|
||||
cy.visit('cypress/support/index.html').then((win) => {
|
||||
win.render({
|
||||
runner: this.runner,
|
||||
specPath: '/foo/bar',
|
||||
|
||||
@@ -17,7 +17,7 @@ describe('test errors', function () {
|
||||
|
||||
this.runner = new EventEmitter()
|
||||
|
||||
cy.visit('/dist').then((win) => {
|
||||
cy.visit('cypress/support/index.html').then((win) => {
|
||||
win.render({
|
||||
runner: this.runner,
|
||||
specPath: '/foo/bar',
|
||||
|
||||
@@ -6,7 +6,7 @@ describe('controls', function () {
|
||||
|
||||
this.runner = new EventEmitter()
|
||||
|
||||
cy.visit('/dist').then((win) => {
|
||||
cy.visit('cypress/support/index.html').then((win) => {
|
||||
win.render({
|
||||
runner: this.runner,
|
||||
specPath: '/foo/bar',
|
||||
|
||||
@@ -6,7 +6,7 @@ describe('controls', function () {
|
||||
|
||||
this.runner = new EventEmitter()
|
||||
|
||||
cy.visit('/dist').then((win) => {
|
||||
cy.visit('cypress/support/index.html').then((win) => {
|
||||
win.render({
|
||||
runner: this.runner,
|
||||
specPath: '/foo/bar',
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
const chai = require('chai')
|
||||
const JSDOM = require('jsdom').JSDOM
|
||||
const sinonChai = require('sinon-chai')
|
||||
|
||||
// http://airbnb.io/enzyme/docs/guides/jsdom.html
|
||||
const jsdom = new JSDOM('<!doctype html><html><body></body></html>')
|
||||
const { window } = jsdom
|
||||
|
||||
global.window = window
|
||||
global.document = window.document
|
||||
global.navigator = {
|
||||
userAgent: 'node.js',
|
||||
}
|
||||
global.requestAnimationFrame = function (callback) {
|
||||
return setTimeout(callback, 0)
|
||||
}
|
||||
global.cancelAnimationFrame = function (id) {
|
||||
clearTimeout(id)
|
||||
}
|
||||
Object.keys(window.document.defaultView).forEach((property) => {
|
||||
if (
|
||||
property === 'localStorage' ||
|
||||
property === 'sessionStorage' ||
|
||||
typeof global[property] !== 'undefined'
|
||||
) return
|
||||
|
||||
global[property] = window.document.defaultView[property]
|
||||
})
|
||||
|
||||
// enzyme, and therefore chai-enzyme, needs to be required after
|
||||
// global.navigator is set up (https://github.com/airbnb/enzyme/issues/395)
|
||||
const enzyme = require('enzyme')
|
||||
const EnzymeAdapter = require('enzyme-adapter-react-16')
|
||||
const chaiEnzyme = require('chai-enzyme')
|
||||
|
||||
enzyme.configure({ adapter: new EnzymeAdapter() })
|
||||
|
||||
chai.use(chaiEnzyme())
|
||||
chai.use(sinonChai)
|
||||
global.expect = chai.expect
|
||||
@@ -2,78 +2,52 @@
|
||||
"name": "@packages/reporter",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"main": "src/main.jsx",
|
||||
"main": "lib/reporter.js",
|
||||
"browser": "src/main",
|
||||
"scripts": {
|
||||
"postinstall": "echo '@packages/reporter needs: npm run build'",
|
||||
"prebuild": "npm run check-deps-pre && rebuild-node-sass",
|
||||
"build": "webpack",
|
||||
"build": "node ./scripts/build-dev.js",
|
||||
"prebuild-prod": "npm run check-deps-pre",
|
||||
"build-prod": "npm run build",
|
||||
"build-prod": "node ./scripts/build-prod.js",
|
||||
"prewatch": "npm run check-deps-pre",
|
||||
"watch": "webpack --watch",
|
||||
"watch": "node ./scripts/watch.js",
|
||||
"check-deps": "node ../../scripts/check-deps.js --verbose",
|
||||
"check-deps-pre": "npm run check-deps -- --prescript",
|
||||
"preclean": "npm run check-deps-pre",
|
||||
"clean": "zunder clean",
|
||||
"clean-deps": "rm -rf node_modules",
|
||||
"pretest": "npm run check-deps-pre",
|
||||
"test": "mocha 'src/**/*.spec.*'",
|
||||
"test-watch": "npm run test -- --watch",
|
||||
"test": "node ./scripts/test.js",
|
||||
"lint": "bin-up eslint --fix lib/*.js scripts/*.js src/*.js* src/**/*.js*",
|
||||
"cypress:open": "node ../../scripts/cypress open --project .",
|
||||
"cypress:run": "node ../../scripts/cypress run --project ."
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
"dist"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.4.4",
|
||||
"@babel/plugin-proposal-class-properties": "^7.3.4",
|
||||
"@babel/plugin-proposal-decorators": "^7.3.0",
|
||||
"@babel/plugin-proposal-object-rest-spread": "7.4.4",
|
||||
"@babel/preset-env": "^7.4.4",
|
||||
"@babel/preset-react": "^7.0.0",
|
||||
"@babel/preset-typescript": "^7.3.3",
|
||||
"@cypress/react-tooltip": "0.4.0",
|
||||
"@types/copy-webpack-plugin": "^4.4.3",
|
||||
"@types/enzyme": "^3.9.1",
|
||||
"@types/html-webpack-plugin": "^3.2.0",
|
||||
"@types/webpack": "^4.4.31",
|
||||
"browser-resolve": "^1.11.3",
|
||||
"babel-loader": "^8.0.6",
|
||||
"bin-up": "1.2.0",
|
||||
"chai": "3.5.0",
|
||||
"chai-enzyme": "1.0.0-beta.1",
|
||||
"classnames": "2.2.6",
|
||||
"clean-webpack-plugin": "^2.0.2",
|
||||
"coffee-loader": "^0.9.0",
|
||||
"copy-webpack-plugin": "^5.0.1",
|
||||
"css-element-queries": "1.1.1",
|
||||
"css-loader": "^2.1.1",
|
||||
"enzyme": "3.9.0",
|
||||
"enzyme-adapter-react-16": "1.12.1",
|
||||
"file-loader": "^3.0.1",
|
||||
"font-awesome": "4.7.0",
|
||||
"html-webpack-plugin": "^3.2.0",
|
||||
"jsdom": "13.2.0",
|
||||
"lodash": "4.17.11",
|
||||
"markdown-it": "6.1.1",
|
||||
"mini-css-extract-plugin": "^0.5.0",
|
||||
"mobx": "3.6.2",
|
||||
"mobx-react": "4.4.3",
|
||||
"mocha": "^6.1.4",
|
||||
"mock-require": "^3.0.3",
|
||||
"node-sass": "^4.12.0",
|
||||
"node-sass-globbing": "^0.0.23",
|
||||
"prop-types": "15.7.2",
|
||||
"react": "16.8.6",
|
||||
"react-dom": "16.8.6",
|
||||
"rebuild-node-sass": "1.1.0",
|
||||
"sass-loader": "^7.1.0",
|
||||
"sinon": "7.0.0",
|
||||
"sinon-chai": "3.3.0",
|
||||
"ts-node": "^8.1.0",
|
||||
"webpack": "^4.31.0",
|
||||
"webpack-cli": "^3.3.2"
|
||||
"zunder": "6.4.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,5 @@
|
||||
"extends": [
|
||||
"plugin:cypress-dev/react",
|
||||
"plugin:cypress-dev/tests"
|
||||
],
|
||||
"parserOptions": {"sourceType": "module"}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -20,11 +20,11 @@ const model = (props) => {
|
||||
describe('Command model', () => {
|
||||
let clock
|
||||
|
||||
beforeEach(() => {
|
||||
before(() => {
|
||||
clock = sinon.useFakeTimers()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
after(() => {
|
||||
clock.restore()
|
||||
})
|
||||
|
||||
|
||||
@@ -371,7 +371,7 @@ describe('<Command />', () => {
|
||||
let runnablesStore
|
||||
let command
|
||||
|
||||
beforeEach(() => {
|
||||
before(() => {
|
||||
clock = sinon.useFakeTimers()
|
||||
})
|
||||
|
||||
@@ -385,6 +385,10 @@ describe('<Command />', () => {
|
||||
/>)
|
||||
})
|
||||
|
||||
after(() => {
|
||||
clock.restore()
|
||||
})
|
||||
|
||||
describe('on mouse over', () => {
|
||||
beforeEach(() => {
|
||||
command.simulate('mouseOver')
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
import './main.scss'
|
||||
import './main'
|
||||
@@ -30,7 +30,7 @@ describe('<FlashOnClick />', () => {
|
||||
let onClick
|
||||
let component
|
||||
|
||||
beforeEach(() => {
|
||||
before(() => {
|
||||
clock = sinon.useFakeTimers()
|
||||
})
|
||||
|
||||
@@ -40,6 +40,10 @@ describe('<FlashOnClick />', () => {
|
||||
component.find('Tooltip').find('.content').simulate('click')
|
||||
})
|
||||
|
||||
after(() => {
|
||||
clock.restore()
|
||||
})
|
||||
|
||||
it('calls props.onClick', () => {
|
||||
expect(onClick).to.have.been.called
|
||||
})
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -22,7 +22,7 @@ const getElement = (props) => {
|
||||
describe('scroller', () => {
|
||||
let clock
|
||||
|
||||
beforeEach(() => {
|
||||
before(() => {
|
||||
clock = sinon.useFakeTimers()
|
||||
})
|
||||
|
||||
@@ -30,6 +30,10 @@ describe('scroller', () => {
|
||||
scroller.__reset()
|
||||
})
|
||||
|
||||
after(() => {
|
||||
clock.restore()
|
||||
})
|
||||
|
||||
it('throws an error if attempting to scroll an element before setting a container', () => {
|
||||
expect(() => {
|
||||
return scroller.scrollIntoView({})
|
||||
|
||||
@@ -6,7 +6,7 @@ $yellow-lightest: #ffffee;
|
||||
|
||||
$header-height: 46px;
|
||||
|
||||
$fa-font-path: '../node_modules/font-awesome/fonts';
|
||||
$fa-font-path: 'fonts';
|
||||
|
||||
$muli: 'Muli', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||
$open-sans: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||
|
||||
@@ -84,4 +84,4 @@ if (window.Cypress) {
|
||||
}
|
||||
}
|
||||
|
||||
export { Reporter }
|
||||
export default { Reporter }
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<div id="app"></div>
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"extends": [
|
||||
"../src/.eslintrc"
|
||||
]
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
import mockRequire from 'mock-require'
|
||||
import { JSDOM } from 'jsdom'
|
||||
const jsdom = new JSDOM('<!doctype html><html><body></body></html>')
|
||||
const { window } = jsdom
|
||||
|
||||
const chai = require('chai')
|
||||
const sinonChai = require('sinon-chai')
|
||||
|
||||
const sinon = require('sinon')
|
||||
|
||||
global.window = window
|
||||
global.document = window.document
|
||||
window.Selection = { prototype: { isCollapsed: {} } }
|
||||
global.navigator = {
|
||||
userAgent: 'node.js',
|
||||
}
|
||||
global.requestAnimationFrame = function (callback) {
|
||||
return setTimeout(callback, 0)
|
||||
}
|
||||
global.cancelAnimationFrame = function (id) {
|
||||
clearTimeout(id)
|
||||
}
|
||||
Object.keys(window.document.defaultView).forEach((property) => {
|
||||
if (
|
||||
property === 'localStorage' ||
|
||||
property === 'sessionStorage' ||
|
||||
typeof global[property] !== 'undefined'
|
||||
) return
|
||||
|
||||
global[property] = window.document.defaultView[property]
|
||||
})
|
||||
|
||||
// enzyme, and therefore chai-enzyme, needs to be required after
|
||||
// global.navigator is set up (https://github.com/airbnb/enzyme/issues/395)
|
||||
const enzyme = require('enzyme')
|
||||
const EnzymeAdapter = require('enzyme-adapter-react-16')
|
||||
const chaiEnzyme = require('chai-enzyme')
|
||||
|
||||
enzyme.configure({ adapter: new EnzymeAdapter() })
|
||||
|
||||
chai.use(chaiEnzyme())
|
||||
chai.use(sinonChai)
|
||||
global.expect = chai.expect
|
||||
|
||||
const returnMockRequire = (name, modExport = {}) => {
|
||||
mockRequire(name, modExport)
|
||||
|
||||
return require(name)
|
||||
}
|
||||
|
||||
const bresolve = require('browser-resolve')
|
||||
const Module = require('module')
|
||||
|
||||
const overrideRequire = () => {
|
||||
|
||||
const _load = Module._load
|
||||
|
||||
Module._load = function (...args) {
|
||||
let browserPkg = args
|
||||
|
||||
if (!['path'].includes(args[0])) {
|
||||
try {
|
||||
browserPkg = [bresolve.sync.apply(this, args)]
|
||||
} catch (e) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
return _load.apply(this, browserPkg)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
overrideRequire()
|
||||
const driver = returnMockRequire('@packages/driver')
|
||||
const io = returnMockRequire('@packages/socket/lib/client', {})
|
||||
|
||||
io.connect = sinon.stub().returns({ emit: () => {}, on: () => {} })
|
||||
|
||||
window.count = (window.count || 0) + 1
|
||||
|
||||
beforeEach(() => {
|
||||
driver.$ = sinon.stub().throws('$ called without being stubbed')
|
||||
io.connect.throws('connect called without being stubbed')
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
sinon.restore()
|
||||
})
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
--require 'test/test-setup'
|
||||
--watch-extensions ts,jsx,tsx
|
||||
--file 'test/helper'
|
||||
@@ -1,21 +0,0 @@
|
||||
require('../../coffee/register')
|
||||
|
||||
require('@babel/register')({
|
||||
'plugins': [
|
||||
// "istanbul",
|
||||
['@babel/plugin-proposal-decorators', { 'legacy': true }],
|
||||
['@babel/plugin-proposal-class-properties', { 'loose': true }],
|
||||
],
|
||||
'presets': ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'],
|
||||
|
||||
// Setting this will remove the currently hooked extensions of `.es6`, `.es`, `.jsx`, `.mjs`
|
||||
// and .js so you'll have to add them back if you want them to be used again.
|
||||
extensions: ['.es6', '.es', '.jsx', '.js', '.mjs', '.ts', '.tsx'],
|
||||
|
||||
ignore: [/node_modules/],
|
||||
// Setting this to false will disable the cache.
|
||||
cache: true,
|
||||
sourceMaps: 'inline',
|
||||
// compact: true,
|
||||
})
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Basic Options */
|
||||
"target": "es2015",
|
||||
"module": "commonjs",
|
||||
/*
|
||||
* Allow javascript files to be compiled.
|
||||
* Override this in modules that need JS
|
||||
*/
|
||||
"allowJs": true,
|
||||
"jsx": "react",
|
||||
"noImplicitAny": false,
|
||||
"noImplicitThis": false,
|
||||
"preserveWatchOutput": true,
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||
/* Generates corresponding '.d.ts' file. */
|
||||
// "declaration": true,
|
||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||
/* Generates corresponding '.map' file. */
|
||||
"sourceMap": true,
|
||||
/* Import emit helpers from 'tslib'. */
|
||||
"importHelpers": true,
|
||||
"strictNullChecks": true,
|
||||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||
/* Strict Type-Checking Options */
|
||||
// "traceResolution": true,
|
||||
"strict": false,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
/**
|
||||
* Skip type checking of all declaration files (*.d.ts).
|
||||
* TODO: Look into changing this in the future
|
||||
*/
|
||||
/* Additional Checks */
|
||||
/* Report errors on unused locals. */
|
||||
// "noEmit": true,
|
||||
"noUnusedLocals": false,
|
||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||
/* Report error when not all code paths in function return a value. */
|
||||
"noImplicitReturns": true,
|
||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
/* Module Resolution Options */
|
||||
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
// "baseUrl": "../", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": ["../driver/src"], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
"typeRoots": ["../driver/node_modules", "../../cli", "../driver/src", "./node_modules"], /* List of folders to include type definitions from. */
|
||||
// "types": [], /* Type declaration files to be included in compilation. */
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"noErrorTruncation": true,
|
||||
"experimentalDecorators": true,
|
||||
// "noResolve": true
|
||||
},
|
||||
"exclude": ["dist"]
|
||||
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
import webpack, { Configuration, optimize, ResolvePlugin } from 'webpack'
|
||||
import _ from 'lodash'
|
||||
import path from 'path'
|
||||
import CleanWebpackPlugin from 'clean-webpack-plugin'
|
||||
import sassGlobImporter = require('node-sass-globbing')
|
||||
import HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
import CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||
import MiniCSSExtractWebpackPlugin = require('mini-css-extract-plugin')
|
||||
|
||||
const mode = process.env.NODE_ENV as ('development' | 'production' | 'test' | 'reporter') || 'development'
|
||||
const webpackmode = mode === 'production' ? mode : 'development'
|
||||
|
||||
const isDevServer = !!process.env.DEV_SERVER
|
||||
const config: webpack.Configuration = {
|
||||
entry: {
|
||||
cypress_reporter: ['./src']
|
||||
},
|
||||
|
||||
|
||||
mode: webpackmode,
|
||||
node: {
|
||||
fs: 'empty',
|
||||
child_process: 'empty',
|
||||
net: 'empty',
|
||||
tls: 'empty',
|
||||
module: 'empty'
|
||||
},
|
||||
resolve: {
|
||||
extensions: [ '.ts', '.js', '.jsx', '.tsx', '.coffee', '.scss', '.json'],
|
||||
},
|
||||
output: {
|
||||
path: path.resolve('./dist'),
|
||||
filename: '[name].js',
|
||||
devtoolModuleFilenameTemplate: '[namespace]/[resource-path]'
|
||||
},
|
||||
|
||||
|
||||
// Enable source maps
|
||||
// devtool: 'inline-cheap-module-source-map',
|
||||
|
||||
stats: {
|
||||
errors: true,
|
||||
warningsFilter: /node_modules\/mocha\/lib\/mocha.js/,
|
||||
warnings: true,
|
||||
all: false,
|
||||
builtAt: true,
|
||||
colors: true,
|
||||
modules: true,
|
||||
maxModules: 20,
|
||||
excludeModules: /main.scss/,
|
||||
},
|
||||
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.coffee/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: require.resolve('coffee-loader'),
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.(ts|js|jsx|tsx)$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: require.resolve('babel-loader'),
|
||||
options: {
|
||||
plugins: [
|
||||
// "istanbul",
|
||||
[require.resolve('@babel/plugin-proposal-decorators'), { legacy: true }],
|
||||
[require.resolve('@babel/plugin-proposal-class-properties'), { loose: true }],
|
||||
],
|
||||
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'],
|
||||
babelrc: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.s?css$/,
|
||||
exclude: /node_modules/,
|
||||
use: [
|
||||
{ loader: MiniCSSExtractWebpackPlugin.loader },
|
||||
{
|
||||
loader: 'css-loader',
|
||||
options: {
|
||||
// sourceMap: true,
|
||||
modules: false,
|
||||
},
|
||||
}, // translates CSS into CommonJS
|
||||
{
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
sourceMap: true,
|
||||
importer: function(...args) {
|
||||
args[0] = args[0].replace(/\\/g, '/')
|
||||
args[1] = args[1].replace(/\\/g, '/')
|
||||
console.log(args)
|
||||
return sassGlobImporter.apply(this, args)
|
||||
},
|
||||
},
|
||||
}, // compiles Sass to CSS, using Node Sass by default
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.(eot|svg|ttf|woff|woff2)$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'file-loader',
|
||||
options: {
|
||||
name: './fonts/[name].[ext]',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
plugins: [
|
||||
new HtmlWebpackPlugin({
|
||||
template: './static/index.html',
|
||||
chunks: ['cypress_reporter']
|
||||
}),
|
||||
new CleanWebpackPlugin(),
|
||||
// new CopyWebpackPlugin([{ from: './static/fonts', to: 'fonts' }]),
|
||||
new MiniCSSExtractWebpackPlugin(),
|
||||
],
|
||||
|
||||
}
|
||||
|
||||
export default config
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
module.exports = require('../../package.json')
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@packages/root",
|
||||
"main": "index.js",
|
||||
"version": "0.0.0",
|
||||
"description": "dummy package pointing at the root package"
|
||||
"description": "dummy package pointing at the root package",
|
||||
"main": "../../package.json"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
const chai = require('chai')
|
||||
const JSDOM = require('jsdom').JSDOM
|
||||
const sinonChai = require('sinon-chai')
|
||||
const $Cypress = require('@packages/driver')
|
||||
const io = require('@packages/socket')
|
||||
|
||||
// http://airbnb.io/enzyme/docs/guides/jsdom.html
|
||||
const jsdom = new JSDOM('<!doctype html><html><body></body></html>')
|
||||
const { window } = jsdom
|
||||
|
||||
global.window = window
|
||||
global.document = window.document
|
||||
global.navigator = {
|
||||
userAgent: 'node.js',
|
||||
}
|
||||
global.requestAnimationFrame = function (callback) {
|
||||
return setTimeout(callback, 0)
|
||||
}
|
||||
global.cancelAnimationFrame = function (id) {
|
||||
clearTimeout(id)
|
||||
}
|
||||
Object.keys(window.document.defaultView).forEach((property) => {
|
||||
if (
|
||||
property === 'localStorage' ||
|
||||
property === 'sessionStorage' ||
|
||||
typeof global[property] !== 'undefined'
|
||||
) return
|
||||
|
||||
global[property] = window.document.defaultView[property]
|
||||
})
|
||||
|
||||
// enzyme, and therefore chai-enzyme, needs to be required after
|
||||
// global.navigator is set up (https://github.com/airbnb/enzyme/issues/395)
|
||||
const enzyme = require('enzyme')
|
||||
const EnzymeAdapter = require('enzyme-adapter-react-16')
|
||||
const chaiEnzyme = require('chai-enzyme')
|
||||
|
||||
enzyme.configure({ adapter: new EnzymeAdapter() })
|
||||
|
||||
chai.use(chaiEnzyme())
|
||||
chai.use(sinonChai)
|
||||
global.expect = chai.expect
|
||||
|
||||
class Runnable {
|
||||
emit () {}
|
||||
}
|
||||
|
||||
class Runner {
|
||||
emit () {}
|
||||
uncaught () {}
|
||||
}
|
||||
|
||||
global.Mocha = { Runnable, Runner }
|
||||
$Cypress.create = () => {}
|
||||
io.connect = () => {
|
||||
return { emit: () => {}, on: () => {} }
|
||||
}
|
||||
@@ -1,22 +1,22 @@
|
||||
{
|
||||
"name": "@packages/runner",
|
||||
"version": "0.0.0",
|
||||
"main": "src/index.js",
|
||||
"main": "lib/runner.js",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"postinstall": "echo '@packages/runner needs: npm run build'",
|
||||
"prebuild": "npm run check-deps-pre && rebuild-node-sass",
|
||||
"build": "webpack",
|
||||
"build": "node ./scripts/build-dev.js",
|
||||
"prebuild-prod": "npm run check-deps-pre",
|
||||
"build-prod": "webpack --mode=production",
|
||||
"build-prod": "node ./scripts/build-prod.js",
|
||||
"prewatch": "npm run check-deps-pre",
|
||||
"watch": "webpack-dev-server",
|
||||
"watch": "node ./scripts/watch.js",
|
||||
"check-deps": "node ../../scripts/check-deps.js --verbose",
|
||||
"check-deps-pre": "npm run check-deps -- --prescript",
|
||||
"clean": "zunder clean",
|
||||
"clean-deps": "rm -rf node_modules",
|
||||
"pretest": "npm run check-deps-pre",
|
||||
"test": "mocha src/**/*.spec.*",
|
||||
"test": "node ./scripts/test.js",
|
||||
"lint": "bin-up eslint --fix scripts/*.js src/*.js* src/**/*.js*"
|
||||
},
|
||||
"files": [
|
||||
@@ -24,62 +24,27 @@
|
||||
"lib"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.4.4",
|
||||
"@babel/plugin-proposal-class-properties": "^7.3.4",
|
||||
"@babel/plugin-proposal-decorators": "^7.3.0",
|
||||
"@babel/plugin-proposal-object-rest-spread": "7.4.4",
|
||||
"@babel/preset-react": "^7.0.0",
|
||||
"@babel/preset-typescript": "^7.3.3",
|
||||
"@babel/register": "^7.4.4",
|
||||
"@cypress/react-tooltip": "0.4.0",
|
||||
"@types/copy-webpack-plugin": "^4.4.3",
|
||||
"@types/enzyme": "^3.9.1",
|
||||
"@types/html-webpack-plugin": "^3.2.0",
|
||||
"@types/react": "^16.8.17",
|
||||
"@types/webpack": "^4.4.25",
|
||||
"@types/webpack-dev-server": "^3.1.5",
|
||||
"babel-loader": "^8.0.5",
|
||||
"bin-up": "1.2.0",
|
||||
"bluebird": "3.5.0",
|
||||
"browser-resolve": "^1.11.3",
|
||||
"chai": "4.2.0",
|
||||
"chai-enzyme": "1.0.0-beta.1",
|
||||
"classnames": "2.2.6",
|
||||
"clean-webpack-plugin": "^2.0.2",
|
||||
"coffee-loader": "^0.9.0",
|
||||
"coffeescript": "^2.4.1",
|
||||
"copy-webpack-plugin": "^5.0.1",
|
||||
"cross-env": "^5.2.0",
|
||||
"css-loader": "^2.1.1",
|
||||
"enzyme": "3.9.0",
|
||||
"enzyme-adapter-react-16": "1.12.1",
|
||||
"extract-text-webpack-plugin": "^4.0.0-beta.0",
|
||||
"file-loader": "^3.0.1",
|
||||
"font-awesome": "4.7.0",
|
||||
"html-webpack-plugin": "^3.2.0",
|
||||
"node-sass-globbing": "^0.0.23",
|
||||
"jquery": "^3.4.1",
|
||||
"jsdom": "13.2.0",
|
||||
"lodash": "4.17.11",
|
||||
"mini-css-extract-plugin": "^0.5.0",
|
||||
"mobx": "3.6.2",
|
||||
"mobx-react": "4.4.3",
|
||||
"mocha": "^6.1.4",
|
||||
"mock-require": "^3.0.3",
|
||||
"node-sass": "^4.11.0",
|
||||
"node-sass-glob-importer": "^5.3.0",
|
||||
"prop-types": "15.7.2",
|
||||
"react": "16.8.6",
|
||||
"react-dom": "16.8.6",
|
||||
"react-input-autosize": "2.2.1",
|
||||
"rebuild-node-sass": "1.1.0",
|
||||
"sass-loader": "^7.1.0",
|
||||
"sinon": "7.0.0",
|
||||
"sinon-chai": "3.3.0",
|
||||
"style-loader": "^0.23.1",
|
||||
"ts-node": "^8.0.3",
|
||||
"webpack": "^4.29.6",
|
||||
"webpack-cli": "^3.2.3",
|
||||
"webpack-dev-server": "^3.3.1"
|
||||
"zunder": "6.4.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import { observer } from 'mobx-react'
|
||||
import PropTypes from 'prop-types'
|
||||
import React, { Component } from 'react'
|
||||
import { findDOMNode } from 'react-dom'
|
||||
import { Reporter } from '@packages/reporter'
|
||||
import $Cypress from '@packages/driver'
|
||||
import { Reporter } from '../../../reporter'
|
||||
import { $ } from '@packages/driver'
|
||||
|
||||
import errorMessages from '../errors/error-messages'
|
||||
import util from '../lib/util'
|
||||
@@ -16,8 +16,6 @@ import Iframes from '../iframe/iframes'
|
||||
import Message from '../message/message'
|
||||
import Resizer from './resizer'
|
||||
|
||||
const $ = $Cypress.$
|
||||
|
||||
@observer
|
||||
class App extends Component {
|
||||
@observable isReporterResizing = false
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import React from 'react'
|
||||
import { shallow } from 'enzyme'
|
||||
import sinon from 'sinon'
|
||||
import driver from '@packages/driver'
|
||||
|
||||
import * as reporter from '@packages/reporter'
|
||||
import reporter from '../../../reporter'
|
||||
import Message from '../message/message'
|
||||
import State from '../lib/state'
|
||||
|
||||
@@ -39,6 +40,13 @@ const shallowRender = (component) => {
|
||||
}
|
||||
|
||||
describe('<App />', () => {
|
||||
beforeEach(() => {
|
||||
driver.$ = () => ({
|
||||
on: () => ({
|
||||
trigger () {},
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
it('renders the reporter wrap with the reporter width', () => {
|
||||
const props = createProps()
|
||||
|
||||
@@ -16,7 +16,7 @@ const getState = (props) => _.extend({
|
||||
|
||||
describe('<Header />', () => {
|
||||
beforeEach(() => {
|
||||
driver.$.returns({ outerHeight: () => 42 })
|
||||
driver.$ = () => ({ outerHeight: () => 42 })
|
||||
})
|
||||
|
||||
it('has showing-selector-playground class if selector playground is open', () => {
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
import './main.scss'
|
||||
import './main.jsx'
|
||||
@@ -2,8 +2,7 @@ import _ from 'lodash'
|
||||
import { EventEmitter } from 'events'
|
||||
import Promise from 'bluebird'
|
||||
import { action } from 'mobx'
|
||||
|
||||
const io = require('@packages/socket/lib/client')
|
||||
import io from '@packages/socket'
|
||||
|
||||
import automation from './automation'
|
||||
import logger from './logger'
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,100 +0,0 @@
|
||||
import mockRequire from 'mock-require'
|
||||
import { JSDOM } from 'jsdom'
|
||||
const jsdom = new JSDOM('<!doctype html><html><body></body></html>')
|
||||
const { window } = jsdom
|
||||
|
||||
const chai = require('chai')
|
||||
const sinonChai = require('sinon-chai')
|
||||
|
||||
global.window = window
|
||||
global.document = window.document
|
||||
window.Selection = { prototype: { isCollapsed: {} } }
|
||||
global.navigator = {
|
||||
userAgent: 'node.js',
|
||||
}
|
||||
global.requestAnimationFrame = function (callback) {
|
||||
return setTimeout(callback, 0)
|
||||
}
|
||||
global.cancelAnimationFrame = function (id) {
|
||||
clearTimeout(id)
|
||||
}
|
||||
Object.keys(window.document.defaultView).forEach((property) => {
|
||||
if (
|
||||
property === 'localStorage' ||
|
||||
property === 'sessionStorage' ||
|
||||
typeof global[property] !== 'undefined'
|
||||
) return
|
||||
|
||||
global[property] = window.document.defaultView[property]
|
||||
})
|
||||
|
||||
// enzyme, and therefore chai-enzyme, needs to be required after
|
||||
// global.navigator is set up (https://github.com/airbnb/enzyme/issues/395)
|
||||
const enzyme = require('enzyme')
|
||||
const EnzymeAdapter = require('enzyme-adapter-react-16')
|
||||
const chaiEnzyme = require('chai-enzyme')
|
||||
|
||||
enzyme.configure({ adapter: new EnzymeAdapter() })
|
||||
|
||||
chai.use(chaiEnzyme())
|
||||
chai.use(sinonChai)
|
||||
global.expect = chai.expect
|
||||
|
||||
const returnMockRequire = (name, modExport = {}) => {
|
||||
mockRequire(name, modExport)
|
||||
|
||||
return require(name)
|
||||
}
|
||||
|
||||
const bresolve = require('browser-resolve')
|
||||
const Module = require('module')
|
||||
|
||||
const overrideRequire = () => {
|
||||
|
||||
const _load = Module._load
|
||||
|
||||
Module._load = function (...args) {
|
||||
let browserPkg = args
|
||||
|
||||
if (!['path'].includes(args[0])) {
|
||||
try {
|
||||
browserPkg = [bresolve.sync.apply(this, args)]
|
||||
} catch (e) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
return _load.apply(this, browserPkg)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
overrideRequire()
|
||||
|
||||
const sinon = require('sinon')
|
||||
|
||||
const driver = returnMockRequire('@packages/driver')
|
||||
const io = returnMockRequire('@packages/socket/lib/client', {})
|
||||
|
||||
io.connect = sinon.stub().returns({ emit: () => {}, on: () => {} })
|
||||
|
||||
const _useFakeTimers = sinon.useFakeTimers
|
||||
let timers = []
|
||||
|
||||
sinon.useFakeTimers = function (...args) {
|
||||
|
||||
const ret = _useFakeTimers.apply(this, args)
|
||||
|
||||
timers.push(ret)
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
driver.$ = sinon.stub().throws('$ called without being stubbed')
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
timers.forEach((clock) => {
|
||||
return clock.restore()
|
||||
})
|
||||
timers = []
|
||||
})
|
||||
@@ -1,3 +0,0 @@
|
||||
--require 'test/test-setup.js'
|
||||
--watch-extensions ts,jsx,tsx
|
||||
--file 'test/helper'
|
||||
@@ -1,22 +0,0 @@
|
||||
|
||||
require('@babel/register')({
|
||||
'plugins': [
|
||||
// "istanbul",
|
||||
['@babel/plugin-proposal-decorators', { 'legacy': true }],
|
||||
['@babel/plugin-proposal-class-properties', { 'loose': true }],
|
||||
],
|
||||
'presets': ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'],
|
||||
|
||||
// Setting this will remove the currently hooked extensions of `.es6`, `.es`, `.jsx`, `.mjs`
|
||||
// and .js so you'll have to add them back if you want them to be used again.
|
||||
extensions: ['.es6', '.es', '.jsx', '.js', '.mjs', '.ts', '.tsx'],
|
||||
|
||||
ignore: [/node_modules/],
|
||||
// Setting this to false will disable the cache.
|
||||
cache: true,
|
||||
// sourceMaps: 'inline',
|
||||
// compact: true,
|
||||
})
|
||||
|
||||
require('coffeescript/register')
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Basic Options */
|
||||
"target": "es2015",
|
||||
"module": "commonjs",
|
||||
/*
|
||||
* Allow javascript files to be compiled.
|
||||
* Override this in modules that need JS
|
||||
*/
|
||||
"allowJs": true,
|
||||
"jsx": "react",
|
||||
"noImplicitAny": false,
|
||||
"noImplicitThis": false,
|
||||
"preserveWatchOutput": true,
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||
/* Generates corresponding '.d.ts' file. */
|
||||
// "declaration": true,
|
||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||
/* Generates corresponding '.map' file. */
|
||||
"sourceMap": true,
|
||||
/* Import emit helpers from 'tslib'. */
|
||||
"importHelpers": true,
|
||||
"strictNullChecks": true,
|
||||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||
/* Strict Type-Checking Options */
|
||||
// "traceResolution": true,
|
||||
"strict": false,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
/**
|
||||
* Skip type checking of all declaration files (*.d.ts).
|
||||
* TODO: Look into changing this in the future
|
||||
*/
|
||||
/* Additional Checks */
|
||||
/* Report errors on unused locals. */
|
||||
// "noEmit": true,
|
||||
"noUnusedLocals": false,
|
||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||
/* Report error when not all code paths in function return a value. */
|
||||
"noImplicitReturns": true,
|
||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
/* Module Resolution Options */
|
||||
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
// "baseUrl": "../", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": ["../driver/src"], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
"typeRoots": ["../driver/node_modules", "../../cli", "../driver/src", "./node_modules"], /* List of folders to include type definitions from. */
|
||||
// "types": [], /* Type declaration files to be included in compilation. */
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"noErrorTruncation": true,
|
||||
"experimentalDecorators": true
|
||||
// "noResolve": true
|
||||
},
|
||||
"exclude": ["dist"]
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
import webpack, { Configuration, optimize, ResolvePlugin } from 'webpack'
|
||||
import _ from 'lodash'
|
||||
import path from 'path'
|
||||
import CleanWebpackPlugin from 'clean-webpack-plugin'
|
||||
import sassGlobImporter = require('node-sass-globbing')
|
||||
import HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
import CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||
import MiniCSSExtractWebpackPlugin = require('mini-css-extract-plugin')
|
||||
|
||||
const mode = process.env.NODE_ENV as ('development' | 'production' | 'test' | 'reporter') || 'development'
|
||||
const webpackmode = mode === 'production' ? mode : 'development'
|
||||
|
||||
// const isDevServer = !!process.env.DEV_SERVER
|
||||
const config: webpack.Configuration = {
|
||||
entry: {
|
||||
cypress_runner: ['./src/index.js'],
|
||||
},
|
||||
mode: webpackmode,
|
||||
node: {
|
||||
fs: 'empty',
|
||||
child_process: 'empty',
|
||||
net: 'empty',
|
||||
tls: 'empty',
|
||||
module: 'empty'
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'react': require.resolve('react')
|
||||
},
|
||||
extensions: [ '.ts', '.js', '.jsx', '.tsx', '.coffee', '.scss', '.json'],
|
||||
},
|
||||
output: {
|
||||
path: path.resolve('./dist'),
|
||||
filename: '[name].js',
|
||||
devtoolModuleFilenameTemplate: '[namespace]/[resource-path]'
|
||||
},
|
||||
|
||||
// Enable source maps
|
||||
// devtool: 'inline-cheap-module-source-map',
|
||||
|
||||
stats: {
|
||||
errors: true,
|
||||
warningsFilter: /node_modules\/mocha\/lib\/mocha.js/,
|
||||
warnings: true,
|
||||
all: false,
|
||||
builtAt: true,
|
||||
colors: true,
|
||||
modules: true,
|
||||
maxModules: 20,
|
||||
excludeModules: /main.scss/,
|
||||
},
|
||||
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.coffee/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: require.resolve('coffee-loader'),
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.(ts|js|jsx|tsx)$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: require.resolve('babel-loader'),
|
||||
options: {
|
||||
plugins: [
|
||||
// "istanbul",
|
||||
[require.resolve('@babel/plugin-proposal-decorators'), { legacy: true }],
|
||||
[require.resolve('@babel/plugin-proposal-class-properties'), { loose: true }],
|
||||
],
|
||||
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'],
|
||||
babelrc: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.s?css$/,
|
||||
exclude: /node_modules/,
|
||||
use: [
|
||||
{ loader: MiniCSSExtractWebpackPlugin.loader },
|
||||
{
|
||||
loader: 'css-loader',
|
||||
options: {
|
||||
// sourceMap: true,
|
||||
modules: false,
|
||||
},
|
||||
}, // translates CSS into CommonJS
|
||||
{
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
sourceMap: true,
|
||||
importer: function(...args) {
|
||||
args[0] = args[0].replace(/\\/g, '/')
|
||||
args[1] = args[1].replace(/\\/g, '/')
|
||||
return sassGlobImporter.apply(this, args)
|
||||
},
|
||||
},
|
||||
}, // compiles Sass to CSS, using Node Sass by default
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.(eot|svg|ttf|woff|woff2)$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'file-loader',
|
||||
options: {
|
||||
name: './fonts/[name].[ext]',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
plugins: [
|
||||
// new DebugWebpackPlugin(),
|
||||
// new debugPlugin(),
|
||||
new HtmlWebpackPlugin({
|
||||
template: './static/index.html',
|
||||
inject: false,
|
||||
}),
|
||||
new CleanWebpackPlugin(),
|
||||
new CopyWebpackPlugin([{ from: './static/fonts', to: 'fonts' }]),
|
||||
new MiniCSSExtractWebpackPlugin(),
|
||||
],
|
||||
|
||||
devServer: {
|
||||
port: 3938,
|
||||
stats: {
|
||||
errors: true,
|
||||
warningsFilter: /node_modules\/mocha\/lib\/mocha.js/,
|
||||
warnings: true,
|
||||
all: false,
|
||||
builtAt: true,
|
||||
colors: true,
|
||||
modules: true,
|
||||
excludeModules: /main\.scss/,
|
||||
},
|
||||
noInfo: true,
|
||||
writeToDisk: true,
|
||||
headers: {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default config
|
||||
|
||||
@@ -53,12 +53,6 @@ https://on.cypress.io/returning-value-and-commands-in-test
|
||||
at stack trace line
|
||||
at stack trace line
|
||||
at stack trace line
|
||||
at stack trace line
|
||||
at stack trace line
|
||||
at stack trace line
|
||||
at stack trace line
|
||||
at stack trace line
|
||||
at stack trace line
|
||||
|
||||
2) errors when invoking commands in custom command and returning differnet value:
|
||||
CypressError: Cypress detected that you invoked one or more cy commands in a custom command but returned a different value.
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
send = require("send")
|
||||
driver = require("@packages/driver")
|
||||
|
||||
module.exports = {
|
||||
handle: (req, res) ->
|
||||
pathToFile = driver.getPathToDist(req.params[0])
|
||||
|
||||
send(req, pathToFile)
|
||||
.pipe(res)
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
_ = require("lodash")
|
||||
send = require("send")
|
||||
reporter = require('@packages/reporter/lib/resolve-dist')
|
||||
reporter = require("@packages/reporter")
|
||||
|
||||
module.exports = {
|
||||
handle: (req, res) ->
|
||||
|
||||
@@ -2,8 +2,8 @@ _ = require("lodash")
|
||||
send = require("send")
|
||||
os = require("os")
|
||||
debug = require("debug")("cypress:server:runner")
|
||||
runner = require("@packages/runner")
|
||||
pkg = require("@packages/root")
|
||||
runner = require("@packages/runner/lib/resolve-dist")
|
||||
|
||||
module.exports = {
|
||||
serve: (req, res, options = {}) ->
|
||||
|
||||
@@ -13,6 +13,7 @@ xhrs = require("./controllers/xhrs")
|
||||
client = require("./controllers/client")
|
||||
files = require("./controllers/files")
|
||||
proxy = require("./controllers/proxy")
|
||||
driver = require("./controllers/driver")
|
||||
staticCtrl = require("./controllers/static")
|
||||
|
||||
module.exports = (app, config, request, getRemoteState, project, nodeProxy) ->
|
||||
@@ -33,6 +34,9 @@ module.exports = (app, config, request, getRemoteState, project, nodeProxy) ->
|
||||
app.get "/__cypress/runner/*", (req, res) ->
|
||||
runner.handle(req, res)
|
||||
|
||||
app.get "/__cypress/driver/*", (req, res) ->
|
||||
driver.handle(req, res)
|
||||
|
||||
app.get "/__cypress/static/*", (req, res) ->
|
||||
staticCtrl.handle(req, res)
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
module.exports = require('./lib/socket')
|
||||
module.exports = require("./lib/socket")
|
||||
@@ -1,9 +1,9 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const server = require('socket.io')
|
||||
const version = require('socket.io/package').version
|
||||
const version = require('socket.io-client/package.json').version
|
||||
const clientPath = require.resolve('socket.io-client')
|
||||
const client = require(clientPath)
|
||||
const client = require('./client')
|
||||
|
||||
module.exports = {
|
||||
server,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"main": "index.js",
|
||||
"browser": "./lib/client.js",
|
||||
"scripts": {
|
||||
"pretest": "npm run check-deps-pre",
|
||||
"test": "cross-env NODE_ENV=test bin-up mocha --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json",
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"parserOptions": {"sourceType": "module"}
|
||||
}
|
||||
@@ -26,7 +26,6 @@ smoke = require("./smoke")
|
||||
packages = require("./util/packages")
|
||||
xvfb = require("../../cli/lib/exec/xvfb")
|
||||
linkPackages = require('../link-packages')
|
||||
{ transformRequires } = require('./util/transform-requires')
|
||||
|
||||
rootPackage = require("@packages/root")
|
||||
|
||||
@@ -122,12 +121,6 @@ buildCypressApp = (platform, version, options = {}) ->
|
||||
|
||||
packages.copyAllToDist(distDir())
|
||||
|
||||
transformSymlinkRequires = ->
|
||||
log("#transformSymlinkRequires")
|
||||
|
||||
transformRequires(distDir())
|
||||
|
||||
|
||||
npmInstallPackages = ->
|
||||
log("#npmInstallPackages")
|
||||
|
||||
@@ -153,6 +146,20 @@ buildCypressApp = (platform, version, options = {}) ->
|
||||
|
||||
fs.outputFileAsync(distDir("index.js"), str)
|
||||
|
||||
copyPackageProxies = (destinationFolder) ->
|
||||
() ->
|
||||
log("#copyPackageProxies")
|
||||
la(check.fn(destinationFolder),
|
||||
"missing destination folder function", destinationFolder)
|
||||
dest = destinationFolder("node_modules", "@packages")
|
||||
la(check.unemptyString(dest), "missing destination folder", dest)
|
||||
source = path.join(process.cwd(), "node_modules", "@packages")
|
||||
fs.unlinkAsync(dest).catch(_.noop)
|
||||
.then(() ->
|
||||
console.log("Copying #{source} to #{dest}")
|
||||
fs.copyAsync(source, dest)
|
||||
)
|
||||
|
||||
removeTypeScript = ->
|
||||
## remove the .ts files in our packages
|
||||
log("#removeTypeScript")
|
||||
@@ -302,13 +309,14 @@ buildCypressApp = (platform, version, options = {}) ->
|
||||
.then(copyPackages)
|
||||
.then(npmInstallPackages)
|
||||
.then(createRootPackage)
|
||||
.then(copyPackageProxies(distDir))
|
||||
.then(convertCoffeeToJs)
|
||||
.then(removeTypeScript)
|
||||
.then(cleanJs)
|
||||
.then(transformSymlinkRequires)
|
||||
.then(testVersion(distDir))
|
||||
.then(elBuilder) # should we delete everything in the buildDir()?
|
||||
.then(removeDevElectronApp)
|
||||
.then(copyPackageProxies(buildAppDir))
|
||||
.then(testVersion(buildAppDir))
|
||||
.then(runSmokeTests)
|
||||
.then(codeSign) ## codesign after running smoke tests due to changing .cy
|
||||
|
||||
+20
-17
@@ -1,7 +1,6 @@
|
||||
_ = require("lodash")
|
||||
fse = require("fs-extra")
|
||||
cp = require("child_process")
|
||||
execa = require('execa')
|
||||
path = require("path")
|
||||
Promise = require("bluebird")
|
||||
os = require("os")
|
||||
@@ -16,24 +15,28 @@ shouldSkipProjectTest = () ->
|
||||
os.platform() == "win32"
|
||||
|
||||
runSmokeTest = (buildAppExecutable) ->
|
||||
rand = "" + Math.random()
|
||||
console.log("executable path #{buildAppExecutable}")
|
||||
new Promise (resolve, reject) ->
|
||||
rand = "" + Math.random()
|
||||
console.log("executable path #{buildAppExecutable}")
|
||||
|
||||
hasRightResponse = (stdout) ->
|
||||
# there could be more debug lines in the output, so find 1 line with
|
||||
# expected random value
|
||||
lines = stdout.split('\n').map((s) -> s.trim())
|
||||
return lines.includes(rand)
|
||||
hasRightResponse = (stdout) ->
|
||||
# there could be more debug lines in the output, so find 1 line with
|
||||
# expected random value
|
||||
lines = stdout.split('\n').map((s) -> s.trim())
|
||||
return lines.includes(rand)
|
||||
|
||||
execa "#{buildAppExecutable}", ["--smoke-test", "--ping=#{rand}"], {timeout: 10000}
|
||||
.catch (err) ->
|
||||
console.error("smoke test failed with error %s", err.message)
|
||||
throw err
|
||||
.then ({stdout}) ->
|
||||
stdout = stdout.replace(/\s/, "")
|
||||
if !hasRightResponse(stdout)
|
||||
throw new Error("Stdout: '#{stdout}' did not match the random number: '#{rand}'")
|
||||
console.log("smokeTest passes")
|
||||
cp.exec "#{buildAppExecutable} --smoke-test --ping=#{rand}", (err, stdout, stderr) ->
|
||||
stdout = stdout.replace(/\s/, "")
|
||||
|
||||
if err
|
||||
console.error("smoke test failed with error %s", err.message)
|
||||
return reject(err)
|
||||
|
||||
if !hasRightResponse(stdout)
|
||||
throw new Error("Stdout: '#{stdout}' did not match the random number: '#{rand}'")
|
||||
else
|
||||
console.log("smokeTest passes")
|
||||
resolve()
|
||||
|
||||
runProjectTest = (buildAppExecutable, e2e) ->
|
||||
if shouldSkipProjectTest()
|
||||
|
||||
@@ -58,18 +58,16 @@ copyAllToDist = (distDir) ->
|
||||
## copies the package to dist
|
||||
## including the default paths
|
||||
## and any specified in package.json files
|
||||
Promise.resolve(fs.readJsonAsync(pathToPackageJson(pkg)))
|
||||
fs.readJsonAsync(pathToPackageJson(pkg))
|
||||
.then (json) ->
|
||||
## grab all the files
|
||||
## and default included paths
|
||||
## and convert to relative paths
|
||||
Promise.resolve(
|
||||
DEFAULT_PATHS
|
||||
.concat(json.files or [])
|
||||
.concat(json.main or [])
|
||||
.map (file) ->
|
||||
path.join(pkg, file)
|
||||
)
|
||||
DEFAULT_PATHS
|
||||
.concat(json.files or [])
|
||||
.concat(json.main or [])
|
||||
.map (file) ->
|
||||
path.join(pkg, file)
|
||||
.map(copyRelativePathToDist, {concurrency: 1})
|
||||
|
||||
## fs-extra concurrency tests (copyPackage / copyRelativePathToDist)
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const glob = require('glob')
|
||||
const chalk = require('chalk')
|
||||
const Promise = require('bluebird')
|
||||
const Debug = require('debug')
|
||||
|
||||
const debug = Debug('cypress:scripts:util:transform-requires')
|
||||
|
||||
const transformRequires = async function (buildResourcePath) {
|
||||
const buildRoot = buildResourcePath
|
||||
|
||||
const globPattern = `${buildRoot}/packages/**/*.js`
|
||||
|
||||
debug({ globPattern })
|
||||
|
||||
const globAsync = await Promise.promisify(glob)
|
||||
|
||||
await globAsync(globPattern, { ignore: ['**/node_modules/**', '**/packages/**/dist/**'] })
|
||||
.map(async (item) => {
|
||||
debug('glob found:', item)
|
||||
const buff = await fs.readFile(item)
|
||||
|
||||
const fileStr = buff.toString()
|
||||
const requireRE = /(require\(["'])@packages\/(\w+)/g
|
||||
|
||||
let shouldWriteFile = false
|
||||
|
||||
// const matches = requireRE.exec(fileStr)
|
||||
const newFile = fileStr.replace(requireRE, (...match) => {
|
||||
console.log()
|
||||
debug(match.slice(0, -1))
|
||||
const pkg = match[2]
|
||||
|
||||
const pkgPath = path.join(buildRoot, `packages/${pkg}`)
|
||||
const replaceWith = path.relative(path.dirname(item), pkgPath).replace(/\\/g, '/')
|
||||
|
||||
console.log('resolve:', chalk.grey(pkgPath), '\nfrom:', chalk.grey(item))
|
||||
console.log(chalk.yellow(`@packages/${pkg}`), '->', chalk.green(replaceWith))
|
||||
|
||||
const replaceString = `${match[1]}${replaceWith}`
|
||||
|
||||
debug(replaceString)
|
||||
|
||||
shouldWriteFile = true
|
||||
|
||||
return replaceString
|
||||
|
||||
})
|
||||
|
||||
if (shouldWriteFile) {
|
||||
debug('writing to file:', chalk.red(item))
|
||||
await fs.writeFile(item, newFile)
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { transformRequires }
|
||||
+124
-25
@@ -4,53 +4,152 @@ const fse = require('fs-extra')
|
||||
const path = require('path')
|
||||
const globber = require('glob')
|
||||
const Promise = require('bluebird')
|
||||
const la = require('lazy-ass')
|
||||
const is = require('check-more-types')
|
||||
const debug = require('debug')('cypress:link')
|
||||
const _ = require('lodash')
|
||||
|
||||
const isRelative = (s) => {
|
||||
return !path.isAbsolute(s)
|
||||
}
|
||||
|
||||
const fs = Promise.promisifyAll(fse)
|
||||
const glob = Promise.promisify(globber)
|
||||
|
||||
const pathToPackages = path.join(__dirname, '..', 'node_modules', '@packages')
|
||||
const pathToPackages = path.join('node_modules', '@packages')
|
||||
|
||||
function deleteOutputFolder () {
|
||||
const wildcard = `${pathToPackages}/*`
|
||||
|
||||
console.log('deleting ', pathToPackages)
|
||||
console.log('deleting all', wildcard)
|
||||
|
||||
return fs.remove(pathToPackages)
|
||||
return glob(wildcard)
|
||||
.map((filename) => {
|
||||
return fs.unlinkAsync(filename)
|
||||
})
|
||||
.catch(_.noop)
|
||||
}
|
||||
|
||||
function makeLinks () {
|
||||
return fs.ensureDir(pathToPackages)
|
||||
.then(() => {
|
||||
return glob('./packages/*/package.json')
|
||||
.map((filename) => {
|
||||
return fs.readJsonAsync(filename)
|
||||
.then((json) => {
|
||||
return { filename, json }
|
||||
})
|
||||
function proxyModule (name, pathToMain, pathToBrowser, pathToTypes) {
|
||||
la(is.unemptyString(name), 'missing name')
|
||||
la(is.unemptyString(pathToMain), 'missing path to main', pathToMain)
|
||||
la(isRelative(pathToMain), 'path to main should be relative', pathToMain)
|
||||
|
||||
const pkg = {
|
||||
name,
|
||||
version: '0.0.0',
|
||||
description: `fake proxy module ${name}`,
|
||||
main: pathToMain,
|
||||
}
|
||||
|
||||
if (pathToBrowser) {
|
||||
la(
|
||||
isRelative(pathToBrowser),
|
||||
'path to browser module should be relative',
|
||||
pathToBrowser
|
||||
)
|
||||
pkg.browser = pathToBrowser
|
||||
}
|
||||
|
||||
if (pathToTypes) {
|
||||
la(
|
||||
isRelative(pathToTypes),
|
||||
'path to types file should be relative',
|
||||
pathToTypes
|
||||
)
|
||||
pkg.types = pathToTypes
|
||||
}
|
||||
|
||||
return pkg
|
||||
}
|
||||
|
||||
function proxyRegister (name) {
|
||||
return `module.exports = require('../../../packages/${name}/register')`
|
||||
}
|
||||
|
||||
function needsRegister (name) {
|
||||
return name === '@packages/coffee' || name === '@packages/ts'
|
||||
}
|
||||
|
||||
function makeProxies () {
|
||||
return glob('./packages/*/package.json')
|
||||
.map((filename) => {
|
||||
return fs.readJsonAsync(filename).then((json) => {
|
||||
return { filename, json }
|
||||
})
|
||||
.map(({ filename }) => {
|
||||
const dirname = path.dirname(filename)
|
||||
const basename = path.basename(dirname)
|
||||
})
|
||||
.map(({ filename, json }) => {
|
||||
if (!json.main) {
|
||||
throw new Error(`Package ${json.name} is missing main`)
|
||||
}
|
||||
|
||||
const destinationLink = path.join(pathToPackages, basename)
|
||||
// const registerPath = path.join(destinationFolder, 'register.js')
|
||||
// const fullMain = path.resolve(dirname, json.main)
|
||||
const dirname = path.dirname(filename)
|
||||
const bareName = json.name.split('/')[1]
|
||||
|
||||
// debug('full name', fullMain)
|
||||
// const relativePathToMain = path.relative(destinationFolder, fullMain)
|
||||
debug(json.name, 'bare name', bareName, 'main', json.main)
|
||||
const destinationFolder = path.join(pathToPackages, bareName)
|
||||
const destPackageFilename = path.join(destinationFolder, 'package.json')
|
||||
const registerPath = path.join(destinationFolder, 'register.js')
|
||||
const fullMain = path.resolve(dirname, json.main)
|
||||
|
||||
// debug('relative path to main', relativePathToMain)
|
||||
const relativePathToDest = path.relative(path.dirname(destinationLink), dirname)
|
||||
debug('full name', fullMain)
|
||||
const relativePathToMain = path.relative(destinationFolder, fullMain)
|
||||
|
||||
console.log(destinationLink, '->', relativePathToDest)
|
||||
debug('relative path to main', relativePathToMain)
|
||||
|
||||
return fs.symlink(relativePathToDest, destinationLink)
|
||||
// for browserify, some packages use "browser" field
|
||||
// need to pass it as well
|
||||
let relativePathToBrowser
|
||||
|
||||
if (is.unemptyString(json.browser)) {
|
||||
debug('package has browser field %s', json.browser)
|
||||
relativePathToBrowser = path.relative(
|
||||
destinationFolder,
|
||||
path.resolve(dirname, json.browser)
|
||||
)
|
||||
debug('relative path to browser', relativePathToBrowser)
|
||||
}
|
||||
|
||||
// if the package has types field, compute new path to it
|
||||
let relativePathTypes
|
||||
|
||||
if (is.unemptyString(json.types)) {
|
||||
debug('package has types field %s', json.types)
|
||||
relativePathTypes = path.relative(
|
||||
destinationFolder,
|
||||
path.resolve(dirname, json.types)
|
||||
)
|
||||
debug('relative path to types', relativePathTypes)
|
||||
}
|
||||
|
||||
const proxy = proxyModule(
|
||||
json.name,
|
||||
relativePathToMain,
|
||||
relativePathToBrowser,
|
||||
relativePathTypes
|
||||
)
|
||||
|
||||
console.log(path.dirname(destPackageFilename), '->', relativePathToMain)
|
||||
|
||||
return fs
|
||||
.outputJsonAsync(destPackageFilename, proxy, { spaces: 2 })
|
||||
.then(() => {
|
||||
if (needsRegister(json.name)) {
|
||||
console.log('adding register file', registerPath)
|
||||
|
||||
return fs.outputFileAsync(
|
||||
registerPath,
|
||||
proxyRegister(bareName),
|
||||
'utf8'
|
||||
)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function linkPackages () {
|
||||
return deleteOutputFolder()
|
||||
.then(makeLinks)
|
||||
.then(makeProxies)
|
||||
.then(() => {
|
||||
console.log('✅ require("@packages/<name>") should work now!')
|
||||
})
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
/* eslint-env mocha */
|
||||
|
||||
const os = require('os')
|
||||
const _ = require('lodash')
|
||||
const path = require('path')
|
||||
const proxyquire = require('proxyquire')
|
||||
const mockfs = require('mock-fs')
|
||||
const _snapshot = require('snap-shot-it')
|
||||
|
||||
const packages = require('../../../binary/util/packages')
|
||||
const { transformRequires } = require('../../../binary/util/transform-requires')
|
||||
|
||||
const snapshot = (...args) => {
|
||||
mockfs.restore()
|
||||
|
||||
return _snapshot(...args)
|
||||
}
|
||||
|
||||
describe('packages', () => {
|
||||
it('can copy files from package.json', async () => {
|
||||
mockfs({
|
||||
'packages': {
|
||||
'coffee': {
|
||||
'package.json': '{"main":"src/main.js", "name": "foo", "files": ["lib"]}',
|
||||
'src': { 'main.js': new Buffer('console.log()') },
|
||||
'lib': { 'foo.js': '{}' },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
await packages.copyAllToDist(os.tmpdir())
|
||||
|
||||
const files = getFs()
|
||||
|
||||
snapshot(files)
|
||||
})
|
||||
|
||||
})
|
||||
describe('transformRequires', () => {
|
||||
|
||||
it('can find and replace symlink requires', async () => {
|
||||
const buildRoot = 'build/linux/Cypress/resources/app'
|
||||
|
||||
mockfs({
|
||||
[buildRoot]: { 'packages': {
|
||||
'foo': {
|
||||
'package.json': '{"main":"src/main.js", "name": "foo", "files": ["lib"]}',
|
||||
'src': { 'main.js': new Buffer('console.log()') },
|
||||
'lib': { 'foo.js': /*js*/`require("@packages/bar/src/main")${''}` },
|
||||
},
|
||||
'bar': {
|
||||
'package.json': '{"main":"src/main.js", "name": "foo", "files": ["lib"]}',
|
||||
'src': { 'main.js': new Buffer('console.log()') },
|
||||
'lib': { 'foo.js': `require("@packages/foo/lib/somefoo")${''}` },
|
||||
'node_modules': { 'no-search.js': '' },
|
||||
'dist': { 'no-search.js': '' },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
await transformRequires(buildRoot)
|
||||
|
||||
// console.log(getFs())
|
||||
|
||||
snapshot(getFs())
|
||||
})
|
||||
|
||||
it('can find and replace symlink requires on win32', async () => {
|
||||
const { transformRequires } = proxyquire('../../../binary/util/transform-requires', { path: path.win32 })
|
||||
const buildRoot = 'build/linux/Cypress/resources/app'
|
||||
|
||||
mockfs({
|
||||
[buildRoot]: { 'packages': {
|
||||
'foo': {
|
||||
'package.json': '{"main":"src/main.js", "name": "foo", "files": ["lib"]}',
|
||||
'src': { 'main.js': new Buffer('console.log()') },
|
||||
'lib': { 'foo.js': /*js*/`require("@packages/bar/src/main")${''}` },
|
||||
},
|
||||
'bar': {
|
||||
'package.json': '{"main":"src/main.js", "name": "foo", "files": ["lib"]}',
|
||||
'src': { 'main.js': new Buffer('console.log()') },
|
||||
'lib': { 'foo.js': `require("@packages/foo/lib/somefoo")${''}` },
|
||||
'node_modules': { 'no-search.js': '' },
|
||||
'dist': { 'no-search.js': '' },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
await transformRequires(buildRoot)
|
||||
|
||||
console.dir(getFs(), { depth: null })
|
||||
|
||||
snapshot(getFs())
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
mockfs.restore()
|
||||
})
|
||||
|
||||
const getFs = () => {
|
||||
const cwd = process.cwd().split('/').slice(1)
|
||||
|
||||
const recurse = (dir, d) => {
|
||||
|
||||
if (_.isString(dir)) {
|
||||
return dir
|
||||
}
|
||||
|
||||
return _.extend({}, ..._.map(dir, (val, key) => {
|
||||
let nextDepth = null
|
||||
|
||||
if (d !== null) {
|
||||
|
||||
if (d === -1) {
|
||||
nextDepth = d + 1
|
||||
} else if (!(d > cwd.length) && key === cwd[d]) {
|
||||
key = 'foo'
|
||||
nextDepth = d + 1
|
||||
|
||||
if (d === cwd.length - 1) {
|
||||
return { '[cwd]': recurse(val._items, nextDepth) }
|
||||
}
|
||||
|
||||
return recurse(val._items, nextDepth)
|
||||
} else {
|
||||
nextDepth = null
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
[key]: recurse(val._content ? val._content.toString() : val._items, nextDepth),
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
return recurse({ root: mockfs.getMockRoot() }, -1).root
|
||||
}
|
||||
@@ -21,8 +21,7 @@ shell.set('-e') // any error is fatal
|
||||
const isRightBranch = () => {
|
||||
const branch = process.env.APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH || process.env.APPVEYOR_REPO_BRANCH
|
||||
|
||||
// TODO: remove 'webpack-runner'
|
||||
return branch === 'develop' || branch === 'webpack-runner'
|
||||
return branch === 'develop'
|
||||
}
|
||||
|
||||
const isForkedPullRequest = () => {
|
||||
|
||||
Reference in New Issue
Block a user