How do you recommend integration testing with the Flexmonster component with Jest? I see here that you recommend using a valid license key. How do you recommend providing that key, particularly when using keys that expire?
Related question:
Some snapshot tests that do not have license keys provided recently began alerting that a trial period has expired, though the source did not change. When a license key is provided, the tests do not have the alert. Can you say what might have changed?
In general, what behavior changes might be expected from one test execution to the next when the source and environment have not changed? We have already noted the random ids used.
Hello Michael,
Thank you for reaching out to us.
Centralize license key management via licenseFilePath
Given your scenario, we recommend setting the key for the test environment via the licenseFilePath
property, which defines a URL to a file with the license key or to a server-side script that returns a license key:
const pivot = new Flexmonster({
container: "pivotContainer",
licenseFilePath: "<URL to a file or a script>"
});
This way, the key would be stored in a single file or endpoint. This key is fetched by Flexmonster during initialization, which resolves the issue of manually updating the license key across multiple branches or environments whenever it changes.
License expiration when no key is provided
After installation, Flexmonster temporarily uses a short-term trial key from our CDN to enable local testing when no license key is provided. This key is intended only for brief evaluation and quickly expires. Eventually, key expiration results in the “trial period expired” alert. Providing a valid license key prevents this.
Using IDs when testing Flexmonster
Note that variations between IDs are expected when the source and environment remain unchanged. Flexmonster dynamically generates unique IDs for some elements, like list elements, which differ from execution to execution. Because of this, tests should rely on stable selectors, which include some IDs, class names, attributes, and tag names.
Please let us know if our answer helped you.
Best regards,
Maksym
Hi Maksym,
Thank you for your suggestions.
Regarding the licenseFilePath property, that would require including network calls in tests that we want isolated from the network. Mocking those network calls would result in the same situation as providing the license directly. Can you suggest other options?
Regarding the changes that might be expected, we are aware that IDs change from one invocation to the next. We are wondering if we might expect any other changes. This might be from randomness, environment changes like the current date, duration of test runs, or other unexpected influences.
Thank you,
Michael
Hello Michael,
Thank you for your reply and clarification.
Setting the license key directly via the licenseKey
property or loading it from the licenseFilePath
are the only available options for providing a license key in Flexmonster.
Could you please share more details about your test project so we can provide the best possible solution? In particular, we would like to know about your network isolation scenario - do you mean that network calls are entirely disallowed during tests, or that you prefer to avoid the repeating network request Flexmonster makes on initialization to fetch the key? We ask because most data sources typically require a network connection unless the data
property provides the inline dataset.
The only expected variation in the behavior between executions is in the automatically generated element IDs. Other component behavior remains stable between runs.
Looking forward to hearing from you.
Best regards,
Maksym
Hi Maksym,
Yes, these tests are intended to have no network access whatsoever. In these cases, data is provided inline.
We noticed that in addition to random ids, the component changed behavior with regard to the license trial alert, described in the related question in the original post. Are other such behavior changes possible? Does providing a license key avoid all such possible behavior changes?
Thanks,
Michael