Comments (11)
@crookse ive tested it on master and it works fine :S
from rhum.
hanks @rags2riches-prog and apologies you encountered this, we'll look into this when we can
from rhum.
@ebebbington Are there any mantainers for this project to be kept relevant and up to date ?
from rhum.
@rags2riches-prog there are, and whilst we intend on doing so for a long time, some of us haven't been able to, and all of us are having a few real life commitments we need to take care of, alongside full time jobs
I'm going to start looking into this now for you
from rhum.
@rags2riches-prog what rhum and deno version are you using? it seems to work fine for me:
import { Rhum } from "./mod.ts"
class Router {
async handle(request: Request): Promise<string|Error> {
return 'test'
}
}
Rhum.testPlan("a.ts", () => {
Rhum.testSuite("router", () => {
Rhum.testCase("handle()", async () => {
const req = new Request("https://google.com")
const router = Rhum.mock(Router).create()
Rhum.asserts.assertEquals(router.calls.handle, 0)
Rhum.asserts.assertEquals(await router.handle(req), "test")
})
})
})
Rhum.run()
$ deno test -A a.ts
from rhum.
@ebebbington thanks for coming back to me, much appreciated.
I am running the last versions for both Deno and Rhum.
The behavior you are trying to reproduce isn't quite the same than the one reported in the OP.
const req = new Request("http://localhost:8080", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify(fakeData)
})
The Request API gets an optional object with details about the request method, headers and a body payload.
The TypeError suggests the property method
of the mocked router cannot be read, unless I am misunderstanding the error.
from rhum.
@ebebbington thanks for coming back to me, much appreciated.
I am running the last versions for both Deno and Rhum.
The behavior you are trying to reproduce isn't quite the same than the one reported in the OP.
const req = new Request("http://localhost:8080", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(fakeData) })
The Request API gets an optional object with details about the request method, headers and a body payload. The TypeError suggests the property
method
of the mocked router cannot be read, unless I am misunderstanding the error.
I donβt suppose you could try importing master of Rhum? Maybe master and the latest version differ somehow: import { Rhum } from β https://raw.githubusercontent.com/drashland/rhum/master/mod.tsβ
from rhum.
this may be an issue with how the mock logic works when it copies over methods and properties. if you (@ebebbington) don't get to it, i'll check it out to see if a native request's properties and methods are all copied over into the mock
based on the method property being undefined, it makes me think it's not being copied over
from rhum.
@ebebbington i verified that this is a bug. your test is missing the part that surfaces the bug. you need to access request.method
in your handle()
method. that's when TypeError: Cannot read properties of undefined (reading 'method')
shows up
from rhum.
@rags2riches-prog, sorry for being late on this. i have a pull request open. it includes a fix for the issue you are seeing.
from rhum.
hey @rags2riches-prog , v1.1.12 was released: https://github.com/drashland/rhum/releases/tag/v1.1.12.
it includes the fix for the issue you are seeing. you shouldn't have to change any code. it should just work, but please let me know if it doesn't. thanks for raising this issue!
from rhum.
Related Issues (20)
- Mocking object with constructorArgs as non-primitive value crashes MockBuilder HOT 7
- Turn rhum into purely a mocking module HOT 1
- After hooks aren't ran if test case fails HOT 1
- Rhum.mock doesn't track nested method calls HOT 3
- Mocked object doesn't process mixin class getter/setter HOT 6
- Release dependency version HOT 2
- Suggestion: Make it QUnit API HOT 1
- feat(v2): spies
- chore(v2): clean up mock tests
- chore(v2): DRY fakes and mocks logic
- feat(v2): mock.expects(...).toBeCalledWith(...)
- feat(v2): support node
- chore(v2): update repo after release
- chore: clean up/improve code documentation for doc.deno.land
- test: error classes HOT 1
- feat: mock.toBeCalledWithArgs(...) HOT 1
- feat: mock.toBeCalledWithoutArgs() HOT 1
- chore: After verifying the calls the counts don't decreased HOT 2
- feat: set arg expectations on methods
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 rhum.