|
1 | 1 | /// <reference path="../support/e2e.ts" /> |
2 | 2 |
|
| 3 | +import dedent from 'dedent' |
| 4 | + |
3 | 5 | describe('Config options', () => { |
4 | 6 | it('supports supportFile = false', () => { |
5 | 7 | cy.scaffoldProject('webpack5_wds5-react') |
@@ -86,3 +88,70 @@ describe('Config options', () => { |
86 | 88 | cy.get('.passed > .num').should('contain', 1) |
87 | 89 | }) |
88 | 90 | }) |
| 91 | + |
| 92 | +describe('sourcemaps', () => { |
| 93 | + it('should be provided for JS and transpiled files', () => { |
| 94 | + const testContent = dedent` |
| 95 | + describe('spec file with import', () => { |
| 96 | + it('should generate uncaught error', () => { |
| 97 | + throw new Error('uncaught') |
| 98 | + }) |
| 99 | + |
| 100 | + it('should generate failed command', () => { |
| 101 | + cy.get('#does-not-exist', { timeout: 100 }) |
| 102 | + }) |
| 103 | + }) |
| 104 | + ` |
| 105 | + |
| 106 | + cy.scaffoldProject('webpack5_wds5-react') |
| 107 | + cy.openProject('webpack5_wds5-react', ['--config-file', 'cypress-webpack-no-support.config.ts', '--component']) |
| 108 | + cy.startAppServer('component') |
| 109 | + |
| 110 | + cy.withCtx(async (ctx, o) => { |
| 111 | + await ctx.actions.file.writeFileInProject( |
| 112 | + 'src/JsErrorSpec.cy.js', |
| 113 | + o.testContent, |
| 114 | + ) |
| 115 | + |
| 116 | + await ctx.actions.file.writeFileInProject( |
| 117 | + 'src/JsWithImportErrorSpec.cy.js', |
| 118 | + `import React from 'react';\n\n${o.testContent}`, |
| 119 | + ) |
| 120 | + |
| 121 | + await ctx.actions.file.writeFileInProject( |
| 122 | + 'src/JsxErrorSpec.cy.jsx', |
| 123 | + o.testContent, |
| 124 | + ) |
| 125 | + }, { testContent }) |
| 126 | + |
| 127 | + const verifySourcemap = (specName: string, line: number, column: number) => { |
| 128 | + cy.visitApp() |
| 129 | + cy.specsPageIsVisible() |
| 130 | + cy.contains(specName).click() |
| 131 | + cy.waitForSpecToFinish() |
| 132 | + cy.get('.failed > .num').should('contain', 2) |
| 133 | + cy.window().then((win) => { |
| 134 | + // @ts-expect-error |
| 135 | + cy.stub(win.getEventManager(), 'emit').as('emit') |
| 136 | + }) |
| 137 | + |
| 138 | + cy.get('.runnable-err-file-path', { timeout: 250 }).eq(1).as('filePath') |
| 139 | + cy.get('@filePath').should('contain', `${specName}:${line}:${column}`) |
| 140 | + cy.get('@filePath').then(($el) => { |
| 141 | + $el.find('span').trigger('click') |
| 142 | + }) |
| 143 | + |
| 144 | + cy.get('@emit').should('have.been.calledWithMatch', 'open:file', { |
| 145 | + absoluteFile: Cypress.sinon.match(new RegExp(`cy-projects/webpack5_wds5-react/src/${specName}$`)), |
| 146 | + line, |
| 147 | + column, |
| 148 | + }) |
| 149 | + } |
| 150 | + |
| 151 | + verifySourcemap('JsErrorSpec.cy.js', 7, 8) |
| 152 | + |
| 153 | + verifySourcemap('JsWithImportErrorSpec.cy.js', 9, 8) |
| 154 | + |
| 155 | + verifySourcemap('JsxErrorSpec.cy.jsx', 7, 8) |
| 156 | + }) |
| 157 | +}) |
0 commit comments