Skip to content

Commit

Permalink
fix: Prevent a couple warnings from being displayed in stdout (#15828)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbreiding authored Apr 7, 2021
1 parent 065446f commit c0cd9f7
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 54 deletions.
5 changes: 0 additions & 5 deletions packages/server/__snapshots__/4_plugin_run_events_spec.ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,6 @@ exports['e2e plugin run events / handles video being deleted in after:spec'] = `
1 passing
Warning: We could not find the video at the following path, so we were unable to process it.
Video path: /foo/bar/.projects/plugin-after-spec-deletes-video/cypress/videos/after_spec_deletes_video.js.mp4
This error will not alter the exit code.
(Results)
Expand Down
7 changes: 0 additions & 7 deletions packages/server/lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,6 @@ const getMsgByType = function (type, arg1 = {}, arg2, arg3) {
This error will not alter the exit code.
${arg1}`
case 'VIDEO_DOESNT_EXIST':
return stripIndent`\
Warning: We could not find the video at the following path, so we were unable to process it.
Video path: ${arg1}
This error will not alter the exit code.`
case 'CHROME_WEB_SECURITY_NOT_SUPPORTED':
return stripIndent`\
Your project has set the configuration option: \`chromeWebSecurity: false\`
Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/modes/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ module.exports = {
if (startedVideoCapture && !videoExists) {
// the video file no longer exists at the path where we expect it,
// likely because the user deleted it in the after:spec event
errors.warning('VIDEO_DOESNT_EXIST', videoName)
debug(`No video found after spec ran - skipping processing. Video path: ${videoName}`)

results.video = null
}
Expand Down
4 changes: 2 additions & 2 deletions packages/server/lib/plugins/child/run_plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const browserLaunch = require('./browser_launch')
const task = require('./task')
const util = require('../util')
const validateEvent = require('./validate_event')
const { registerTsNode } = require('../../util/ts-node')
const tsNodeUtil = require('./ts_node')

let registeredEventsById = {}
let registeredEventsByName = {}
Expand Down Expand Up @@ -164,7 +164,7 @@ const runPlugins = (ipc, pluginsFile, projectRoot) => {
})

if (!tsRegistered) {
registerTsNode(projectRoot, pluginsFile)
tsNodeUtil.register(projectRoot, pluginsFile)

// ensure typescript is only registered once
tsRegistered = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const debug = require('debug')('cypress:server:ts-node')
const path = require('path')
const tsnode = require('ts-node')
const resolve = require('./resolve')
const resolve = require('../../util/resolve')

const getTsNodeOptions = (tsPath, pluginsFile) => {
return {
Expand All @@ -16,7 +16,7 @@ const getTsNodeOptions = (tsPath, pluginsFile) => {
}
}

const registerTsNode = (projectRoot, pluginsFile) => {
const register = (projectRoot, pluginsFile) => {
try {
const tsPath = resolve.typescript(projectRoot)

Expand All @@ -36,5 +36,5 @@ const registerTsNode = (projectRoot, pluginsFile) => {
}

module.exports = {
registerTsNode,
register,
}
5 changes: 3 additions & 2 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,11 @@
"productName": "Cypress",
"workspaces": {
"nohoist": [
"@benmalka/foxdriver"
"@benmalka/foxdriver",
"tsconfig-paths"
]
},
"optionalDependencies": {
"registry-js": "1.13.0"
}
}
}
13 changes: 13 additions & 0 deletions packages/server/patches/tsconfig-paths+3.9.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/node_modules/tsconfig-paths/lib/register.js b/node_modules/tsconfig-paths/lib/register.js
index c12b996..8beea8c 100644
--- a/node_modules/tsconfig-paths/lib/register.js
+++ b/node_modules/tsconfig-paths/lib/register.js
@@ -51,7 +51,7 @@ function register(explicitParams) {
explicitParams: explicitParams
});
if (configLoaderResult.resultType === "failed") {
- console.warn(configLoaderResult.message + ". tsconfig-paths will be skipped");
+ // console.warn(configLoaderResult.message + ". tsconfig-paths will be skipped");
return noOp;
}
var matchPath = match_path_sync_1.createMatchPath(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths, configLoaderResult.mainFields, configLoaderResult.addMatchAll);
12 changes: 0 additions & 12 deletions packages/server/test/unit/modes/run_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,18 +590,6 @@ describe('lib/modes/run', () => {
fs.pathExists.resolves(false)
})

it('logs warning', function () {
return runMode.waitForTestsToFinishRunning({
project: this.projectInstance,
startedVideoCapture: new Date(),
videoName: 'foo.mp4',
endVideoCapture: sinon.stub().resolves(),
})
.then(() => {
expect(errors.warning).to.be.calledWith('VIDEO_DOESNT_EXIST', 'foo.mp4')
})
})

it('does not process or upload video', function () {
return runMode.waitForTestsToFinishRunning({
project: this.projectInstance,
Expand Down
33 changes: 11 additions & 22 deletions packages/server/test/unit/plugins/child/run_plugins_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ require('../../../spec_helper')

const _ = require('lodash')
const snapshot = require('snap-shot-it')
const tsnode = require('ts-node')
const Promise = require('bluebird')

const preprocessor = require(`${root}../../lib/plugins/child/preprocessor`)
const task = require(`${root}../../lib/plugins/child/task`)
const runPlugins = require(`${root}../../lib/plugins/child/run_plugins`)
const util = require(`${root}../../lib/plugins/util`)
const resolve = require(`${root}../../lib/util/resolve`)
const browserUtils = require(`${root}../../lib/browsers/utils`)
const Fixtures = require(`${root}../../test/support/helpers/fixtures`)
const tsNodeUtil = require(`${root}../../lib/plugins/child/ts_node`)

const runPlugins = require(`${root}../../lib/plugins/child/run_plugins`)

const colorCodeRe = /\[[0-9;]+m/gm
const pathRe = /\/?([a-z0-9_-]+\/)*[a-z0-9_-]+\/([a-z_]+\.\w+)[:0-9]+/gmi
Expand Down Expand Up @@ -94,37 +95,25 @@ describe('lib/plugins/child/run_plugins', () => {
})

describe('typescript registration', () => {
beforeEach(function () {
this.register = sinon.stub(tsnode, 'register')
beforeEach(() => {
sinon.stub(tsNodeUtil, 'register')
sinon.stub(resolve, 'typescript').returns('/path/to/typescript.js')
})

it('registers ts-node if typescript is installed', function () {
it('registers ts-node', function () {
runPlugins(this.ipc, '/path/to/plugins/file.js', 'proj-root')

expect(this.register).to.be.calledWith({
transpileOnly: true,
compiler: '/path/to/typescript.js',
dir: '/path/to/plugins',
compilerOptions: {
module: 'CommonJS',
},
})
expect(tsNodeUtil.register).to.be.calledWith(
'proj-root',
'/path/to/plugins/file.js',
)
})

it('only registers ts-node once', function () {
runPlugins(this.ipc, '/path/to/plugins/file.js', 'proj-root')
runPlugins(this.ipc, '/path/to/plugins/file.js', 'proj-root')

expect(this.register).to.be.calledOnce
})

it('does not register ts-node if typescript is not installed', function () {
resolve.typescript.returns(null)

runPlugins(this.ipc, '/path/to/plugins/file.js', 'proj-root')

expect(this.register).not.to.be.called
expect(tsNodeUtil.register).to.be.calledOnce
})
})

Expand Down
44 changes: 44 additions & 0 deletions packages/server/test/unit/plugins/child/ts_node_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
require('../../../spec_helper')

const tsnode = require('ts-node')

const resolve = require(`${root}../../lib/util/resolve`)

const tsNodeUtil = require(`${root}../../lib/plugins/child/ts_node`)

describe('lib/plugins/child/ts_node', () => {
beforeEach(() => {
sinon.stub(tsnode, 'register')
sinon.stub(resolve, 'typescript').returns('/path/to/typescript.js')
})

describe('typescript registration', () => {
it('registers ts-node if typescript is installed', () => {
tsNodeUtil.register('proj-root', '/path/to/plugins/file.js')

expect(tsnode.register).to.be.calledWith({
transpileOnly: true,
compiler: '/path/to/typescript.js',
dir: '/path/to/plugins',
compilerOptions: {
module: 'CommonJS',
},
})
})

it('does not register ts-node if typescript is not installed', () => {
resolve.typescript.returns(null)

tsNodeUtil.register('proj-root', '/path/to/plugins/file.js')

expect(tsnode.register).not.to.be.called
})

it('prevents tsconfig-paths from logging warning when there is no tsconfig.json', () => {
sinon.spy(console, 'warn')
tsNodeUtil.register('proj-root', '/path/to/plugins/file.js')

expect(console.warn).not.to.be.calledWith('Missing baseUrl in compilerOptions. tsconfig-paths will be skipped')
})
})
})

4 comments on commit c0cd9f7

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on c0cd9f7 Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.0.1/circle-develop-c0cd9f78c39b9ded9bf343706399b07dd811e195/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on c0cd9f7 Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.0.1/appveyor-develop-c0cd9f78c39b9ded9bf343706399b07dd811e195/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on c0cd9f7 Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.0.1/appveyor-develop-c0cd9f78c39b9ded9bf343706399b07dd811e195/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on c0cd9f7 Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.0.1/circle-develop-c0cd9f78c39b9ded9bf343706399b07dd811e195/cypress.tgz

Please sign in to comment.