mocha-examples | Working examples of common configurations using mocha ☕️ | Runtime Evironment library
kandi X-RAY | mocha-examples Summary
kandi X-RAY | mocha-examples Summary
A set of examples to help demontrate common configurations using Mocha. They should all run out-the-box.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Constructs a new Base reporter instance .
mocha-examples Key Features
mocha-examples Examples and Code Snippets
Community Discussions
Trending Discussions on mocha-examples
QUESTION
I was watching this video in order to learn how to add some simple tests to my Express routes but I am getting all kind of errors while executing a test. The error is:
import * as chai from 'chai';
^^^^^^
SyntaxError: Cannot use import statement outside a module
I have read some similar Stack Overflow questions and GitHub issues but I didn't find a solution for my own application. Finally I found Mocha documentation on GitHub regarding ES modules but it didn't work:
I created the app using TypeScript and CommonJS module to transpile, so I added "test": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha src/test/*.ts"
to the package.json
scripts but I am getting the same error every time. I am using ts-node
as a server.
Anyway, this is my tsconfig.json
file:
ANSWER
Answered 2020-May-06 at 12:05Had the same issue and almost gave up using Mocha with TypeScript (in our case Angular 9).
This is what helped me:
In tsconfig.json:
Replaced this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install mocha-examples
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page