mbolotov / cypress-intellij-reporter

Intermediary mocha reporter for enabling Cypress support inside WebStorm and other IntelliJ IDEs with NodeJS support
Apache License 2.0
5 stars 1 forks source link

A failure with the test code is being masked by the mocha reporter. #3

Closed kodriscollics closed 2 years ago

kodriscollics commented 3 years ago

Environment:

Issue: I have a test which is failing upon execution. It appears that the cypress-intellij-reporter is displaying an error which is masking the real problem with the code. This is the test code:

            //Sorting by NAME asc
            cy.task('log', '  Testing sorted by NAME ascending...')
            cy.getByID('unitNameNumberHeader').click()

            cy.get('#dataTable')
                .should('have.length.above', 0)
                .scrapeTable()
                .then((table) => {
                        expect(table.columnLabels).to.deep.eq([
                            'Task #',
                            'Name ↓',
                            'Date Received',
                            'Type',
                            'Group'])

                        expect(table.isPropertySorted(['name'], ['asc'])).to.be.true
                    }
                )

When the above code is executed within IntelliJ, the test fails and the following error is generated:

warn mocha-intellij: cannot load "./lib/utils". Caused by Error: Cannot find module 'mocha' Require stack: C:\dev\TestApp\node_modules\cypress-intellij-reporter\lib\cypressIntellijUtil.js C:\dev\TestApp\node_modules\cypress-intellij-reporter\lib\cypressIntellijTree.js C:\dev\TestApp\node_modules\cypress-intellij-reporter\index.js C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\lib\reporter.js C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\lib\project-base.js C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\lib\project_static.js C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\lib\modes\run.js C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\lib\modes\run-e2e.js C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\lib\modes\index.js C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\lib\cypress.js C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\index.js C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\index.js at Module._resolveFilename (internal/modules/cjs/loader.js:887:15) at Function.n._resolveFilename (electron/js2c/browser_init.js:257:1128) at Function.resolve (internal/modules/cjs/helpers.js:94:19) at findMochaInnerDependency (C:\dev\TestApp\node_modules\cypress-intellij-reporter\lib\cypressIntellijUtil.js:213:35) at requireMochaModule (C:\dev\TestApp\node_modules\cypress-intellij-reporter\lib\cypressIntellijUtil.js:184:29) at Object.requireMochaUtils (C:\dev\TestApp\node_modules\cypress-intellij-reporter\lib\cypressIntellijUtil.js:278:24) at Object.stringify (C:\dev\TestApp\node_modules\cypress-intellij-reporter\lib\cypress-intellij-stringifier.js:10:29) at finishTestNode (C:\dev\TestApp\node_modules\cypress-intellij-reporter\index.js:211:35) at Runner. (C:\dev\TestApp\node_modules\cypress-intellij-reporter\index.js:383:7) at Runner. (C:\dev\TestApp\node_modules\cypress-intellij-reporter\lib\cypressIntellijUtil.js:129:17) at Runner.emit (events.js:327:22) at Reporter.emit (C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\lib\reporter.js:333:46) at ProjectBase. (C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\lib\project-base.js:449:34) at Generator.next (:null:null) at C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\node_modules\tslib\tslib.js:117:75 at new Promise (:null:null) at Object.__awaiter (C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\node_modules\tslib\tslib.js:113:16) at Object.onMocha (C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\lib\project-base.js:442:51) at Socket. (C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\lib\socket-base.js:213:40) at Socket.emit (events.js:315:20) at Socket.emitUntyped (C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io\dist\typed-events.js:69:22) at C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\socket\node_modules\socket.io\dist\socket.js:428:39 at processTicksAndRejections (internal/process/task_queues.js:75:11) { code: 'MODULE_NOT_FOUND', requireStack: [ 'C:\dev\TestApp\node_modules\cypress-intellij-reporter\lib\cypressIntellijUtil.js', 'C:\dev\TestApp\node_modules\cypress-intellij-reporter\lib\cypressIntellijTree.js', 'C:\dev\TestApp\node_modules\cypress-intellij-reporter\index.js', 'C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\lib\reporter.js', 'C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\lib\project-base.js', 'C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\lib\project_static.js', 'C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\lib\modes\run.js', 'C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\lib\modes\run-e2e.js', 'C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\lib\modes\index.js', 'C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\lib\cypress.js', 'C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\index.js', 'C:\Users\kodriscoll\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\index.js', undefined ] } AssertionError: expected false to be true Expected :"true" Actual :false

However, when I exit IntelliJ and run the test at a Windows CMD line, the test still fails for other reasons, but, of course, the above error message is not displayed. The cypress-intellij-reporter appears to be generating an error message upon test failure which is preventing the true test failure errors from surfacing.

mbolotov commented 3 years ago

Hi Kent, Thanks for the report! Could you provide a sample project to reproduce the problem? Or, at least, the package.json file?

kodriscollics commented 3 years ago

Thanks for the reply. I have copied the package.json below. I can't produce a sample project as the code and the DB are internal use to the company and are behind our corporate firewall :-( If it would help, I could share the cypress DEBUG output which I have saved and redacted a little. I could also share the section of HTML in question from dev tools.

{ "name": "qa-tests", "version": "1.0.0", "description": "UI Testing", "private": true, "main": "index.js", "scripts": { "kotest": "echo \"Error: no test specified\" && exit 1" }, "author": "kodriscoll", "devDependencies": { "@cypress/code-coverage": "^3.9.10", "babel-plugin-istanbul": "^6.0.0", "cypress": "^8.3.0", "cypress-harvester": "^1.1.0", "cypress-intellij-reporter": "0.0.6", "cypress-log-to-output": "^1.1.2", "cypress-plugin-tab": "^1.0.5", "cypress-sql-server": "^1.0.0", "cypress-wait-until": "^1.7.1", "cypress-xpath": "^1.6.2", "istanbul-lib-coverage": "^3.0.0", "nyc": "^15.1.0", "typescript": "^4.3.5" }, "dependencies": { "cypress-waitfor": "^1.1.0", "jdbc": "^0.7.6", "node": "^10.24.1", } }

mbolotov commented 2 years ago

hi @kodriscollics! could you try to update to 0.0.7 cypress-intellij-reporter? It should fix this problem.

kodriscollics commented 2 years ago

@mbolotov ... Thank you! I'm no longer seeing this.