Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make dev-server error message appear only once when CT is not configured #17090

Merged
merged 5 commits into from
Jun 27, 2021

Conversation

elevatebart
Copy link
Contributor

@elevatebart elevatebart commented Jun 23, 2021

User facing changelog

Simplified the error when the event dev-server:start is not configured and users start the component testing

How has the user experience changed?

Before:

Error: It is required to register dev-server plugin that implements `dev-server:start` event for component testing.
    at Object.start (/Users/bart/Documents/github/cypress/packages/server/lib/plugins/dev-server.js:36:13)
    at /Users/bart/Documents/github/cypress/packages/server-ct/src/project-ct.ts:100:45
From previous event:
    at /Users/bart/Documents/github/cypress/packages/server-ct/src/project-ct.ts:99:18
    at processImmediate (internal/timers.js:461:21)
From previous event:
    at ProjectCt._initPlugins (/Users/bart/Documents/github/cypress/packages/server-ct/src/project-ct.ts:91:14)
    at onOpen (/Users/bart/Documents/github/cypress/packages/server-ct/src/project-ct.ts:50:29)
    at callback (/Users/bart/Documents/github/cypress/node_modules/graceful-fs/polyfills.js:299:20)
    at callback (/Users/bart/Documents/github/cypress/packages/server/node_modules/graceful-fs/polyfills.js:289:20)
    at FSReqCallback.oncomplete (fs.js:184:5)
From previous event:
    at ProjectCt.open (/Users/bart/Documents/github/cypress/packages/server/lib/project-base.ts:124:14)
    at ProjectCt.open (/Users/bart/Documents/github/cypress/packages/server-ct/src/project-ct.ts:47:22)
    at Object.create (/Users/bart/Documents/github/cypress/packages/server/lib/open_project.js:353:26)
    at /Users/bart/Documents/github/cypress/packages/server-ct/index.ts:66:39
    at processImmediate (internal/timers.js:461:21)
Error: It is required to register dev-server plugin that implements `dev-server:start` event for component testing.
    at Object.start (/Users/bart/Documents/github/cypress/packages/server/lib/plugins/dev-server.js:36:13)
    at /Users/bart/Documents/github/cypress/packages/server-ct/src/project-ct.ts:100:45
From previous event:
    at /Users/bart/Documents/github/cypress/packages/server-ct/src/project-ct.ts:99:18
    at processImmediate (internal/timers.js:461:21)
From previous event:
    at ProjectCt._initPlugins (/Users/bart/Documents/github/cypress/packages/server-ct/src/project-ct.ts:91:14)
    at onOpen (/Users/bart/Documents/github/cypress/packages/server-ct/src/project-ct.ts:50:29)
    at callback (/Users/bart/Documents/github/cypress/node_modules/graceful-fs/polyfills.js:299:20)
    at callback (/Users/bart/Documents/github/cypress/packages/server/node_modules/graceful-fs/polyfills.js:289:20)
    at FSReqCallback.oncomplete (fs.js:184:5)
From previous event:
    at ProjectCt.open (/Users/bart/Documents/github/cypress/packages/server/lib/project-base.ts:124:14)
    at ProjectCt.open (/Users/bart/Documents/github/cypress/packages/server-ct/src/project-ct.ts:47:22)
    at Object.create (/Users/bart/Documents/github/cypress/packages/server/lib/open_project.js:353:26)
    at /Users/bart/Documents/github/cypress/packages/server-ct/index.ts:66:39
    at processImmediate (internal/timers.js:461:21)
✨  Done in 26.45s.
✨  Done in 26.70s.

After:

yarn workspace v1.22.10
yarn run v1.22.10
$ node ../../scripts/cypress.js open-ct --project ${PWD}
(node:62958) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `Cypress --trace-warnings ...` to show where the warning was created)
To run component-testing, cypress needs the `dev-server:start` event.

Implement it by adding a `on('dev-server:start', () => startDevServer())` call in your pluginsFile.

You can find the 'pluginsFile' at the following path:

/Users/AppleSeed/project/cypress/plugins/index.js

To learn more about how to set up component testing:

https://on.cypress.io/component-testing

✨  Done in 21.16s.
✨  Done in 21.41s.

@elevatebart elevatebart requested a review from a team as a code owner June 23, 2021 21:41
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 23, 2021

Thanks for taking the time to open a PR!

@elevatebart elevatebart requested review from chrisbreiding and jennifer-shehane and removed request for a team June 23, 2021 21:41
@cypress
Copy link

cypress bot commented Jun 23, 2021



Test summary

8448 0 101 4Flakiness 2


Run details

Project cypress
Status Passed
Commit a0b675a
Started Jun 26, 2021 2:04 PM
Ended Jun 26, 2021 2:15 PM
Duration 11:14 💡
OS Linux Debian - 10.8
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

reporter.errors.spec.js Flakiness
1 errors ui > uncaught errors > spec Bluebird unhandled rejection
retries.ui.spec.js Flakiness
1 runner/cypress retries.ui.spec > opens attempt on each attempt failure for the screenshot, and closes after test passes

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@@ -965,6 +965,14 @@ const getMsgByType = function (type, arg1 = {}, arg2, arg3) {

${chalk.yellow(arg2)}
`
case 'CT_NO_DEV_START_EVENT':
return stripIndent`\
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Can we not include the \ in the message:

To run component-testing, cypress needs the \`dev-server:start\` event. 

The \ look a bit weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The backslash are not in the command message. They are only necessary for the backticks to be displayed in the final error.
My description was confusing.

(I did a poor Copy-Paste)

@@ -32,8 +33,7 @@ const API = {

start ({ specs, config }) {
if (!plugins.has('dev-server:start')) {
// TODO: add link to the documentation in the error message
throw new Error('It is required to register dev-server plugin that implements `dev-server:start` event for component testing.')
return errors.throw('CT_NO_DEV_START_EVENT', config.pluginsFile)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the second arg (config.pluginsFile) needed? Seems it is not used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, my plan was to use it in the error to offer a clickable target for the user.

Here is the path to your pluginsFile: /Users/dev/path

@elevatebart elevatebart force-pushed the fix/show-dev-server-error-once branch from f686c60 to f006452 Compare June 24, 2021 14:14
@elevatebart elevatebart merged commit 20de3e5 into develop Jun 27, 2021
tgriesser added a commit that referenced this pull request Jun 30, 2021
* develop:
  fix: prevent saved state errors for deprecated keys (#17093)
  fix(studio): restore intro modal styles (#17118)
  refactor: add @packages/resolve-dist to isolate client/server code (#17109)
  fix: plugin file referenced by cypress config in angular schematics (#17143)
  refactor: @packages/runner-shared should also be devDependencies (#17133)
  chore: release @cypress/schematic-v1.4.1
  fix: plugin file in angular schematics (#17141)
  chore(runner): render spec list inline (behind feature flag) (#17069)
  refactor: remove junk test (#17125)
  chore(server): collapse project-ct and project-e2e into project-base (#17115)
  fix: make dev-server error message appear only once when CT is not configured (#17090)
  chore: release @cypress/schematic-v1.4.0
  feat: add ng generate to @cypress/schematic to generate e2e spec files (#16962)
  feat(studio): add ability to copy commands to clipboard (#16912)
  chore: release @cypress/webpack-preprocessor-v5.9.1
  chore: release @cypress/webpack-batteries-included-preprocessor-v2.2.2
  chore: release @cypress/vue-v3.0.0-beta.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Double errors in component testing
2 participants