cypress-io / cypress-webpack-preprocessor

Cypress preprocessor for bundling JavaScript via webpack
93 stars 22 forks source link

fix: Reduce the verbosity of error messages #102

Closed chrisbreiding closed 4 years ago

chrisbreiding commented 4 years ago

Webpack's errors can be overly verbose. This reduces them to only useful information.

Module Not Found Before:

Error: Webpack Compilation Error
./cypress/integration/record_error_spec.coffee
Module not found: Error: Can't resolve '../it/does/not/exist' in '/foo/bar/.projects/e2e/cypress/integration'
resolve '../it/does/not/exist' in '/foo/bar/.projects/e2e/cypress/integration'
  using description file: /foo/bar/.projects/e2e/package.json (relative path: ./cypress/integration)
    Field 'browser' doesn't contain a valid alias configuration
    using description file: /foo/bar/.projects/e2e/package.json (relative path: ./cypress/it/does/not/exist)
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        /foo/bar/.projects/e2e/cypress/it/does/not/exist doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        /foo/bar/.projects/e2e/cypress/it/does/not/exist.js doesn't exist
      .json
        Field 'browser' doesn't contain a valid alias configuration
        /foo/bar/.projects/e2e/cypress/it/does/not/exist.json doesn't exist
      .jsx
        Field 'browser' doesn't contain a valid alias configuration
        /foo/bar/.projects/e2e/cypress/it/does/not/exist.jsx doesn't exist
      .coffee
        Field 'browser' doesn't contain a valid alias configuration
        /foo/bar/.projects/e2e/cypress/it/does/not/exist.coffee doesn't exist
      .ts
        Field 'browser' doesn't contain a valid alias configuration
        /foo/bar/.projects/e2e/cypress/it/does/not/exist.ts doesn't exist
      .tsx
        Field 'browser' doesn't contain a valid alias configuration
        /foo/bar/.projects/e2e/cypress/it/does/not/exist.tsx doesn't exist
      as directory
        /foo/bar/.projects/e2e/cypress/it/does/not/exist doesn't exist
[/foo/bar/.projects/e2e/cypress/it/does/not/exist]
[/foo/bar/.projects/e2e/cypress/it/does/not/exist.js]
[/foo/bar/.projects/e2e/cypress/it/does/not/exist.json]
[/foo/bar/.projects/e2e/cypress/it/does/not/exist.jsx]
[/foo/bar/.projects/e2e/cypress/it/does/not/exist.coffee]
[/foo/bar/.projects/e2e/cypress/it/does/not/exist.ts]
[/foo/bar/.projects/e2e/cypress/it/does/not/exist.tsx]
 @ ./cypress/integration/record_error_spec.coffee 1:0-31
 @ multi ./cypress/integration/record_error_spec.coffee

Module Not Found After:

Error: Webpack Compilation Error
./cypress/integration/record_error_spec.coffee
Module not found: Error: Can't resolve '../it/does/not/exist' in '/foo/bar/.projects/e2e/cypress/integration'
Looked for and couldn't find the file at the following paths:
[/foo/bar/.projects/e2e/cypress/it/does/not/exist]
[/foo/bar/.projects/e2e/cypress/it/does/not/exist.js]
[/foo/bar/.projects/e2e/cypress/it/does/not/exist.json]
[/foo/bar/.projects/e2e/cypress/it/does/not/exist.jsx]
[/foo/bar/.projects/e2e/cypress/it/does/not/exist.coffee]
[/foo/bar/.projects/e2e/cypress/it/does/not/exist.ts]
[/foo/bar/.projects/e2e/cypress/it/does/not/exist.tsx]
 @ ./cypress/integration/record_error_spec.coffee 1:0-31
 @ multi ./cypress/integration/record_error_spec.coffee

**Syntax Error Before:***

Error: Webpack Compilation Error
describe('fail', - > ); ./cypress/integration/typescript_failing_spec.tsXX:XX
                   ^    Module parse failed: Unexpected token (4:19)
ParseError: Unexpected token    File was processed with these loaders:
 * ../../../../node_modules/@cypress/webpack-batteries-included-preprocessor/node_modules/ts-loader/index.js
You may need an additional loader to handle the result of these loaders.
| // The code below is ignored by eslint
| // because it tests failing spec.
> describe('fail', - > );
| 
 @ multi ./cypress/integration/typescript_failing_spec.ts main[0]
 /foo/bar/.projects/e2e/cypress/integration/typescript_failing_spec.ts
./cypress/integration/typescript_failing_spec.ts
[tsl] ERROR in /foo/bar/.projects/e2e/cypress/integration/typescript_failing_spec.ts(3,19)
      TS1109: Expression expected.
 @ multi ./cypress/integration/typescript_failing_spec.ts main[0]
 /foo/bar/.projects/e2e/cypress/integration/typescript_failing_spec.ts
./cypress/integration/typescript_failing_spec.ts
[tsl] ERROR in /foo/bar/.projects/e2e/cypress/integration/typescript_failing_spec.ts(3,21)
      TS1109: Expression expected.
 @ multi ./cypress/integration/typescript_failing_spec.ts main[0]

**Syntax Error After:***

Error: Webpack Compilation Error
describe('fail', - > ); ./cypress/integration/typescript_failing_spec.tsXX:XX
                   ^    Module parse failed: Unexpected token (4:19)
ParseError: Unexpected token    File was processed with these loaders:
 * ../../../../node_modules/@cypress/webpack-batteries-included-preprocessor/node_modules/ts-loader/index.js
You may need an additional loader to handle the result of these loaders.
| // The code below is ignored by eslint
| // because it tests failing spec.
> describe('fail', - > );
| 
chrisbreiding commented 4 years ago

@Bkucera I now have it removing everything after '@ multi' in error messages, as that seems to all be extra nonsense.

chrisbreiding commented 4 years ago

:tada: This PR is included in version 5.4.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: