-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using intermock
in tests ?
#53
Comments
I've also tried running it in CLI and received:
|
So, it seems that it doesn't like some of my types that look like: interface TypeA {
info: {
id: number,
name: string
}
} If I extract the type like this: interface TypeA {
info: TypeAInfo
}
interface TypeAInfo {
id: number,
name: string
} It works great in CLI 🤔 I'm still doing something wrong when calling the |
If I understood the API correctly this should work: import {mock} from 'intermock'
import fs from 'fs'
describe('generate mocked types', () => {
it('should generate mocked types', () => {
const mck = mock({
files: [['./types.ts', fs.readFileSync('./types.ts')]],
interfaces: ['MyType']
})
console.log(mck)
}
}) |
Ah, so I need to actually read the file contents - didn't think of that, will test and get back with the result |
Any luck? I'm trying intermock with CLI and in typescript tests and it doesn't work when the needed interface is in another file. I tried including files both in CLI and in typescript and it doesn't work... The only solution is to put all interfaces in one file. |
Would anyone be willing to put together a small codesandbox example of this working for testing as proposed? It would be really helpful. Maybe even enough to include in the docs cause I'm a little lost here. |
For anyone reading this, you need to specify the file contents as a string: files: [['./types.ts', fs.readFileSync('./types.ts').toString()]] |
Hello there and thank you for this great project!
I wanted to use
intermock
to generate stub data while testing. I tried to run it as:But whenever I run this,
mck
is empty ({}
) - any idea what I'm doing wrong ? There's no error printed to the terminal, so I'm thinking that I'm doing something wrong somewhere 🤔The text was updated successfully, but these errors were encountered: