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

Unit tests need a hook to prefill the objects/states DB #14

Closed
AlCalzone opened this issue Mar 11, 2019 · 7 comments
Closed

Unit tests need a hook to prefill the objects/states DB #14

AlCalzone opened this issue Mar 11, 2019 · 7 comments
Assignees
Labels
bug Something isn't working Test:Unit

Comments

@AlCalzone
Copy link
Collaborator

AlCalzone commented Mar 11, 2019

@AlCalzone AlCalzone self-assigned this Mar 11, 2019
@AlCalzone AlCalzone added the bug Something isn't working label Mar 11, 2019
@AlCalzone AlCalzone changed the title Integration tests need a hook to prefill the objects/states DB Unit tests need a hook to prefill the objects/states DB Mar 11, 2019
@paveltsytovich
Copy link

Hi,

How I fill config.native before run onReady in unit test? I need test synchronization config.native (from admin web page config data) and iobroker object database.

@AlCalzone
Copy link
Collaborator Author

By default the tests take what is defined in io-package.json

@paveltsytovich
Copy link

By default the tests take what is defined in io-package.json

It`s not appropriate, because I need test following cases:

  • Add new row in my web admin page. It is should be correct synchronization with iobroker database
  • Delete row in my web admin page. It is should be correct synchronization with iobroker database
  • Change exists row in my web admin page. It is should be correct synchronization with iobroker database
  • Receive from low-level device some command by my adapter. It is should be correct change state in iobroker database
  • Call from user code SetState function. It is should be correct state change in my adapter and send correct command to low-level device

I think that adapter should be create in each test suite (for example in describe->beforeEach may be) or is there another way to test my adapter

@AlCalzone
Copy link
Collaborator Author

So you want to dynamically change the adapter config before each test?

@paveltsytovich
Copy link

So you want to dynamically change the adapter config before each test?

Yes. I need configure my adapter or emit command from low-level device (via mock) before each test.

@Apollon77
Copy link
Collaborator

Also needed in some cases where default values can not be used for testing ...

@AlCalzone
Copy link
Collaborator Author

There is now the property overwriteAdapterConfig on the test options object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Test:Unit
Projects
None yet
Development

No branches or pull requests

3 participants