Mocha TypeError when running test
See original GitHub issueWhat are you trying to achieve?
Run test with :
npx codeceptjs run search_test.js
What do you get instead?
Provide console output if related. Use
--verbose
mode for more details.
TypeError: Cannot set property id of #<Test> which has only a getter
at /home/gil/dev/heig/amt/OverFlow/e2e/node_modules/codeceptjs/lib/mochaFactory.js:53:46
at Array.forEach (<anonymous>)
at Suite.eachTest (/home/gil/dev/heig/amt/OverFlow/e2e/node_modules/mocha/lib/suite.js:438:14)
at /home/gil/dev/heig/amt/OverFlow/e2e/node_modules/mocha/lib/suite.js:440:11
at Array.forEach (<anonymous>)
at Suite.eachTest (/home/gil/dev/heig/amt/OverFlow/e2e/node_modules/mocha/lib/suite.js:439:15)
at Mocha.mocha.loadFiles (/home/gil/dev/heig/amt/OverFlow/e2e/node_modules/codeceptjs/lib/mochaFactory.js:53:21)
at Mocha.run (/home/gil/dev/heig/amt/OverFlow/e2e/node_modules/mocha/lib/mocha.js:970:10)
at /home/gil/dev/heig/amt/OverFlow/e2e/node_modules/codeceptjs/lib/codecept.js:170:15
at new Promise (<anonymous>)
Cannot set property id of #<Test> which has only a getter
TypeError:
at /home/gil/dev/heig/amt/OverFlow/e2e/node_modules/codeceptjs/lib/mochaFactory.js:53:46
at Array.forEach (<anonymous>)
at Suite.eachTest (/home/gil/dev/heig/amt/OverFlow/e2e/node_modules/mocha/lib/suite.js:438:14)
at /home/gil/dev/heig/amt/OverFlow/e2e/node_modules/mocha/lib/suite.js:440:11
at Array.forEach (<anonymous>)
at Suite.eachTest (/home/gil/dev/heig/amt/OverFlow/e2e/node_modules/mocha/lib/suite.js:439:15)
at Mocha.mocha.loadFiles (/home/gil/dev/heig/amt/OverFlow/e2e/node_modules/codeceptjs/lib/mochaFactory.js:53:21)
at Mocha.run (/home/gil/dev/heig/amt/OverFlow/e2e/node_modules/mocha/lib/mocha.js:970:10)
at /home/gil/dev/heig/amt/OverFlow/e2e/node_modules/codeceptjs/lib/codecept.js:170:15
at new Promise (<anonymous>)
Provide test source code if related
Content of search_test.js
:
Feature('search');
Scenario('test search title', ({ I }) => {
I.amOnPage('/')
I.fillField('s', 'question 2')
I.click('Search')
I.see('Question 2')
I.see('Contenu 2')
I.dontSee('Question 1')
I.dontSee('Contenu 1')
I.dontSee('Question 3')
I.dontSee('Contenu 3')
});
Scenario('test search author', ({ I }) => {
I.amOnPage('/')
I.fillField('s', 'gil')
I.click('Search')
I.see('Question 1')
I.see('Contenu 1')
I.dontSee('Question 2')
I.dontSee('Contenu 2')
I.dontSee('Question 3')
I.dontSee('Contenu 3')
});
Details
- CodeceptJS version: 3.0.0
- NodeJS Version: 12.18.4
- Operating System: Manjaro Linux
- Using Playwright 1.5.1
Configuration file
const { setHeadlessWhen } = require('@codeceptjs/configure');
// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);
exports.config = {
tests: './*_test.js',
output: './output',
helpers: {
Playwright: {
url: 'http://localhost:9080/overflow',
show: true,
browser: 'chromium'
}
},
include: {
I: './steps_file.js'
},
bootstrap: null,
mocha: {},
name: 'e2e',
translation: 'fr-FR',
plugins: {
pauseOnFail: {},
retryFailedStep: {
enabled: true
},
tryTo: {
enabled: true
},
screenshotOnFail: {
enabled: true
}
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:10
Top Results From Across the Web
Mocha Unit Testing: Uncaught TypeError: Cannot read ...
I get the error Uncaught TypeError: Cannot read property 'apply' of undefined . let chai = require('chai') let chaiHttp = require('chai- ...
Read more >Getting error when I run my test using mocha
When I run this using node 'filename' it is running fine with no issue. When I run using mocha node_modules/mocha/bin/mocha 'filename' I am ......
Read more >mochajs/mocha - Gitter
What is the suggested way to run mocha units tests with 'debugger' in the test code? ... I get a Type error: timeout...
Read more >Mocha documentation — DevDocs
When a test file is loaded, Mocha executes all of its suites and finds–but does not execute–any hooks and tests therein. Top-level hooks,...
Read more >Failed to run mocha tests if mocha configured to ... - YouTrack
Create a test using a mocha test runner · Run the test via IDE using the following options parallel: true or --parallel CLI...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have this same error as well, with the project that I just setup an hour ago. I fixed this by adding
mocha
topackage.json
as well, with the version pin to"mocha": "8.1.3",
. I think this is more likely an issue frommocha@8.2.0
, which was released 3 days ago https://github.com/mochajs/mocha/releases/tag/v8.2.0.Quick fix
Open your
package.json
and specify explicitly the version 8.1.3 of Mocha :Apparently the bug occurs with the Mocha 8.2.0 update. This should temporarily fix the problem.