Skip to content

Commit

Permalink
Converting some class stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
tgriesser committed Feb 28, 2019
1 parent ef810f5 commit 1f9c5af
Show file tree
Hide file tree
Showing 5 changed files with 357 additions and 364 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"devDependencies": {
"@types/bluebird": "^3.5.26",
"@types/node": "^8.2.1",
"@types/ramda": "^0.25.51",
"@types/randomstring": "^1.1.6",
"@types/minimist": "^1.2.0",
"@types/debug": "^4.1.2",
Expand Down
41 changes: 19 additions & 22 deletions packages/server/lib/modes/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ import debugLib from 'debug'
import Promise from 'bluebird'
import logSymbols from 'log-symbols'
import { FoundBrowser } from '@packages/launcher'
import Bluebird from 'bluebird'

import recordMode from './record.coffee'
import errors from '../errors.coffee'
import Project from '../project.coffee'
import { Project } from '../project'
import Reporter from '../reporter.coffee'
import browsers from '../browsers.coffee'
import openProject from '../open_project.coffee'
Expand Down Expand Up @@ -336,11 +337,11 @@ const iterateThroughSpecs = function(options = {}) {
} = options

const serial = () => {
return Promise.mapSeries(specs, runEachSpec)
return Bluebird.mapSeries(specs, runEachSpec)
}

const serialWithRecord = () => {
return Promise.mapSeries(specs, (spec, index, length) => {
return Bluebird.mapSeries(specs, (spec, index, length) => {
return beforeSpecRun(spec)
.then(({ estimated }) => {
return runEachSpec(spec, index, length, estimated)
Expand Down Expand Up @@ -401,21 +402,17 @@ const iterateThroughSpecs = function(options = {}) {
}
}

export const getProjectId = function(project) {
export const getProjectId = Bluebird.method((project: Project) => {
const id = env.get('CYPRESS_PROJECT_ID')

//# if we have an ID just use it
if (id) {
return Promise.resolve(id)
return id
}

return project.getProjectId().catch(() =>
//# no id no problem
{
return null
}
)
}
//# no id no problem
return project.getProjectId().catchReturn(null)
})

const reduceRuns = (runs, prop) => {
return _.reduce(
Expand All @@ -432,7 +429,7 @@ const getRun = (run, prop) => {
}

export const writeOutput = (outputPath, results) => {
return Promise.try(() => {
return Bluebird.try(() => {
if (!outputPath) {
return
}
Expand Down Expand Up @@ -491,7 +488,7 @@ const createAndOpenProject = function(socketId: string, options: OptionsArgv) {
}
)
.then((project) => {
return Promise.props({
return Bluebird.props({
project,
config: project.getConfig(),
projectId: getProjectId(project),
Expand All @@ -510,10 +507,10 @@ const removeOldProfiles = () => {

const trashAssets = function(config = {}) {
if (config.trashAssetsBeforeRuns !== true) {
return Promise.resolve()
return Bluebird.resolve()
}

return Promise.join(
return Bluebird.join(
trash.folder(config.videosFolder),
trash.folder(config.screenshotsFolder)
).catch((err) =>
Expand Down Expand Up @@ -786,12 +783,12 @@ module.exports = {
let attempts = 0

return (waitForBrowserToConnect = () => {
return Promise.join(
return Bluebird.join(
this.waitForSocketConnection(project, socketId),
this.launchBrowser(options)
)
.timeout(timeout != null ? timeout : 30000)
.catch(Promise.TimeoutError, (err) => {
.catch(Bluebird.TimeoutError, (err) => {
attempts += 1

console.log('')
Expand Down Expand Up @@ -1082,14 +1079,14 @@ module.exports = {
}
}

return Promise.resolve(recording).then((props = {}) => {
return Bluebird.resolve(recording).then((props = {}) => {
//# extract the started + ended promises from recording
const { start, end, write } = props

//# make sure we start the recording first
//# before doing anything
return Promise.resolve(start).then((started) => {
return Promise.props({
return Bluebird.resolve(start).then((started) => {
return Bluebird.props({
results: this.waitForTestsToFinishRunning({
end,
name,
Expand Down Expand Up @@ -1174,7 +1171,7 @@ export function ready(optionsArgv: OptionsArgv) {
recordMode.throwIfIndeterminateCiBuildId(ciBuildId, parallel, group)
}

return Promise.all([
return Bluebird.all([
system.info(),
browsers.ensureAndGetByNameOrPath(browserName),
this.findSpecs(config, specPattern),
Expand Down
4 changes: 2 additions & 2 deletions packages/server/lib/open_project.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ debug = require("debug")("cypress:server:openproject")
Promise = require("bluebird")
files = require("./controllers/files")
config = require("./config")
Project = require("./project")
{Project} = require("./project")
browsers = require("./browsers")
specsUtil = require("./util/specs")
preprocessor = require("./plugins/preprocessor")
Expand Down Expand Up @@ -176,7 +176,7 @@ create = ->

create: (path, args = {}, options = {}) ->
## store the currently open project
openProject = Project(path)
openProject = new Project(path)

_.defaults(options, {
onReloadBrowser: (url, browser) =>
Expand Down

0 comments on commit 1f9c5af

Please sign in to comment.