-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Given that i have added chai/require-expect to the require array in mocharc.yml
When i run npx mocha
Then it should include expect as a global function
-- Actually --
I get the following error:
TSError: ⨯ Unable to compile TypeScript: test/isthisforfun.spec.ts:7:9 - error TS2304: Cannot find name 'expect'.
mocharc.yml
allow-uncaught: false
async-only: false
bail: false
check-leaks: false
color: true
delay: false
diff: true
exit: false # could be expressed as "no-exit: true"
extension:
- ts
forbid-only: false
forbid-pending: false
full-trace: false
# fgrep and grep are mutually exclusive
# grep: something
growl: false
ignore:
- node_modules
- src
inline-diffs: false
# needs to be used with grep or fgrep
# invert: false
recursive: false
reporter: spec
require:
- "ts-node/register"
- "chai/register-expect"
retries: 1
slow: 75
sort: false
spec: test/**/*.spec.ts # the positional arguments!
timeout: false # same as "no-timeout: true" or "timeout: 0"
trace-warnings: true # node flags ok
ui: bdd
v8-stack-trace-limit: 100 # V8 flags are prepended with "v8-"
watch: false
watch-files:
- 'test/**/*.ts'
tsconfig.json
{
"compilerOptions": {
"target": "es6",
"lib": ["es2019"],
"module": "commonjs",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noResolve": false,
"noEmitOnError": false,
"noImplicitAny": true,
"declaration": true,
"sourceMap": true,
"outDir": "dist/",
"moduleResolution": "node",
"preserveSymlinks": true,
"skipLibCheck": true,
"types": [ "node", "mocha" ],
"typeRoots": [
"node_modules/@types"
]
},
"include": [
"src/**/*.ts",
"test/**/*.ts"
],
"exclude": [
"node_modules"
]
}
package.json
{
"name": "isthisforfun",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/chai": "^4.2.11",
"@types/mocha": "^7.0.2",
"@types/node": "^13.9.2",
"babel": "^6.23.0",
"chai": "^4.2.0",
"mocha": "^7.1.1",
"ts-mocha": "^7.0.0",
"ts-node": "^8.7.0",
"typescript": "^3.8.3"
},
"dependencies": {
"@types/axios": "^0.14.0",
"axios": "^0.19.2"
}
}
Hack Fix
If i include the library as an import in each test it passes
import { expect } from 'chai'; // Using Expect style
Metadata
Metadata
Assignees
Labels
No labels