Comments (10)
I guess this is a problem related to your tsconfig. Probably moduleResolution
: it should be set to at least Node16
Otherwise, please share your tsconfig.json
from runner.
This is my tsconfig.json
:
{
"compilerOptions": {
"moduleResolution": "node16",
"target": "es2022",
"module": "node16",
"lib": [
"es2019",
"esnext.asynciterable",
"esnext.bigint"
],
"strict": true,
"sourceMap": true,
"inlineSourceMap": false,
"declaration": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noImplicitAny": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"declarationDir": "dist",
"allowImportingTsExtensions": true,
"noEmit": true,
"outDir": "dist"
},
"include": [
"src",
"tests"
]
}
The error message:
~/co/ts-postgres$ npx tsc 2🚫
tests/hello.test.ts:8:28 - error TS2339: Property 'assert' does not exist on type 'TestContext'.
8 test('add two numbers', ({ assert }: TestContext) => {
~~~~~~
Found 1 error in tests/hello.test.ts:8
from runner.
Thanks!
where is your test.ts file located? i'm talking about the file that contains this:
import { configure, processCLIArgs, run } from '@japa/runner'
import { assert } from '@japa/assert'
import { expect } from '@japa/expect'
processCLIArgs(process.argv.splice(2))
configure({
files: ['tests/**/*.spec.ts'],
plugins: [assert(), expect()],
})
run()
If you keep the default location, it should be in ./bin/test.ts
. And if this is the case, you need to include it in your include
tsconfig :
{
"compilerOptions" : {
// ....
},
"include" : [
"bin", // Here
"src",
"tests"
]
}
Otherwise, the module augmentation performed by importing @japa/assert will not be effective
from runner.
Adding "bin" (where my "test.ts" file resides) actually does not change anything. Nor does using "node16" as the module resolution setting.
from runner.
Did you tried restarting the typescript server / editor after updating that ? ( I am pretty sure this is the solution )
Otherwise, can you provide a reproduction repo please?
from runner.
@Julien-R44 see https://github.com/malthe/japa-runner/tree/typing-issue – thanks!
from runner.
It works just fine for me dude :
So yeah, i believe this was related to include
.
from runner.
I set up a workflow to run via GitHub Actions on that same repo.
Here's a run that demonstrates the error: https://github.com/malthe/japa-runner/actions/runs/7293525876/job/19876751955.
from runner.
You need to remove the TestContext
annotation on this line : https://github.com/malthe/japa-runner/blob/1261dd00584b4594c2ac911297df71ff67be57a1/tests/math.test.ts#L8
You don't need it. This should works :
test('add two numbers', ({ assert }) => {
assert.equal(sum(2, 2), 4)
})
And, if ever you need it the augmented TestContext type, you should import it through @japa/runner/core
not @japa/core
+ import type { TestContext } from '@japa/runner/core';
- import type { TestContext } from '@japa/core';
from runner.
Thanks – works beautifully 🎄
from runner.
Related Issues (20)
- Need HTML Test report HOT 3
- Add help commands to "processCliArgs" HOT 1
- Add `--reporters` argument HOT 15
- Trying to upload non-existing file hangs test suite HOT 6
- Open APIs to get the current test/group and file name from a plugin HOT 9
- Property 'expect' does not exist on type TextContext HOT 2
- Bug with assertAgainstApiSpec on Adonisjs HOT 8
- Config `importer` function returns wrong path when using ESM loader HOT 4
- Planning Japa version 3 HOT 21
- Awesome Japa HOT 4
- Can't use project's root folder in runner config HOT 3
- Missing type declaration for nested module import `@japa/runner/reporters` HOT 4
- Plugin-augmented properties (e.g. assert) not available in Deno HOT 2
- [META] endless loop when trying to create a feature request issue on github HOT 6
- Question: Flag to bail / fail early? HOT 1
- Consider adding snapshot `hint` HOT 3
- 'npm init japa' fails with '@japa/browser-client' HOT 2
- Discussion for a new feature - changedSince option HOT 1
- Test runner doesn't print an error trace on CI
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from runner.