Skip to content
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

How to mock in tests #109

Open
yereby opened this issue Apr 27, 2018 · 8 comments
Open

How to mock in tests #109

yereby opened this issue Apr 27, 2018 · 8 comments

Comments

@yereby
Copy link

yereby commented Apr 27, 2018

Hi,

I have an appli where i use telnet.connect like that :

const params = {
  host: self.host,
  port: 23,
  shellPrompt: '~ #',
  timeout: 0,
  password: '*****',
}
telnet = new Telnet()
await telnet.connect(params)

It works fine, but know a write my tests and i can't manage to mock the telnet connect.
Does someone have any advice ?

Thanks.

@mkozjak
Copy link
Owner

mkozjak commented May 3, 2018

Hi! The only way to mock this is to create a simple telnet server using the telnet library. Please, check tests here, you'll see an example written.

@yereby
Copy link
Author

yereby commented May 3, 2018

Hi,
Thanks for the answer. What about creating a fake server in here ?
Like node-serialport did, they added a mocking feature.
See here https://github.com/node-serialport/node-serialport#testing

@mkozjak
Copy link
Owner

mkozjak commented May 3, 2018

Hi,

Makes sense. Would you be interested in implementing such stuff? PRs are welcome.

@yereby
Copy link
Author

yereby commented May 3, 2018

Yep with pleasure.
I'll do it in my app and back port here

@mkozjak
Copy link
Owner

mkozjak commented May 15, 2018

@yereby Any news on a PR, maybe?

@yereby
Copy link
Author

yereby commented May 15, 2018

@mkozjak not for now i am a little busy but it will come soon

@mkozjak
Copy link
Owner

mkozjak commented Jun 6, 2019

@yereby Maybe did this in the end? :)

@yereby
Copy link
Author

yereby commented Jun 11, 2019

Hi @mkozjak unfortunately the project was delayed, and i don't have enough time to work on this issue.
Really sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants