Test script caching
To be reliable, tests must be consistent and repeatable. To ensure this, the SDK will cache the results of successful extractions into a test script that can be reused in subsequent test runs.
Customizing the cache directory
You can configure the location of the cache directory by changing the cacheDir
parameter:
sdk = new SDK(
browser,
// This will store the files in a directory named after the test file
path.join(__dirname, path.parse(__filename).name),
// ...
);
This directory, and the resulting cached test scripts, should be committed to your source control system.
Invalidating the cache
When you change your HTML significantly, your tests will start to fail since the tests are testing the old HTML. If this is expected, you can invalidate the cache by deleting the appropriate directory. This will force the SDK to re-extract a new test script the next time it is run.
Invalidating the cache of an entire test case
For example, if you wish to invalidate the cache for the tests contained within tests/my_test.test.js
, you should delete the tests/my_test.test
directory:
rm -rf tests/my_test.test
Invalidating the cache of a single test
If you only wish to invalidate a single test and not the entire test case, you can delete the sub-directory that matches your test name.
For example, if you wish to invalidate the cache for the It should do my action
test, you should delete the tests/my_test.test/It should do my action
directory:
rm -rf "tests/my_test.test/It should do my action"
Real-world example
You can find an example of what the cache structure looks like by looking at the internal SDK tests.