I have generated Kibana plugin using Yo. It consists of test file inside server/test. I have looked in test cases in kibana-dev\test\functional\apps\visualize for different visualizations too.
In kibana dev, it seems it requires Services and page objects to test the plugin. Here are my few doubts:
npm run test:server is not executing any test inside export default function ({ getService, getPageObjects }) {}
If i have to write test cases according to kibana-dev\test\functional\apps\visualize tests, should i add methods like clickCircle(), getCircle() inside page_objects\visualize_page.js for my plugin or such methods can be implemented in my test file itself?
First, the yo generator is deprecated. If you want to create a plugin, use the template-kibana-plugin instead. The yo generator is no longer actively maintained.
Second, I'm not sure what you're trying to accomplish in your first code snippet. This looks like you've added code to the server/tests/index.js file, but I am not sure why there are tests within export default function. The way that tests are structured in kibana plugins, is the tests and code that is being tested are defined in separate files. For example:
Third, there seems to be some confusion about the nature of the tests you're trying to write. You claim that you're trying to write server-side tests, but mention concepts related to client-side tests. These are two separate ideas and use different logic.
Last, There is no out-of-the-box test coverage library included in the plugin template, or yo generated plugin. That is up to you.
Where should I pass/create mock data for custom plugin? How can I mock the data as, we are developing a plugin which doesn't use schema rather uses a custom es query?
You can run the es_archiver from the command line to save some data you created in Elasticsearch by whatever means you want. And then in your test you would load that data. If it's time-based data (typically is) then in your test you would always set the Kibana timepicker to the same exact time so you always get the same results on that data. Like await PageObjects.header.setAbsoluteRange(fromTime, toTime);
If you're creating a new plugin, I would create a new Page Object file for the methods needed to access the objects in your plugin page.
You would typically run the UI tests by starting the Elasticsearch and Kibana server like npm run test:ui:server
and then running the tests like; node scripts/functional_test_runner
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.