Constructor
#
new JasmineMatchers()
Methods
#
(static) installMatchers()
Install the jasmine matchers in this class using jasmine globals. This must be run before methods such as
expect(a).toBeSimilarToImage(b). (It is automatically run when using the nes-test
binary.)
#
(static) toBeIdenticalToImage(actual, expected)
Compares an image generated by the emulator with another image you provide. This will succeed only if
every pixel in the image matches.
Parameters:
Name |
Type |
Description |
actual |
String
|
The path to the image generated by the emulator. (This is what goes in expect()) |
expected |
String
|
The path to the image on your system to compare with. (This is what goes in.toBeSimilarToImage()) |
Returns:
Success if all pixels match, otherwse failure.
Example
Compares two images, to verify whether they are at least 80% similar.
// Take a screenshot of the intro screen
const testImage = await emulator.takeScreenshot('intro-screen.png');
// Do a comparison that shows that all pixels match.
expect(testImage).toBeIdenticalToImage('./data/intro-screenshot.png');
#
(static) toBeSimilarToImage(actual, expected)
Compares an image generated by the emulator with another image you provide. This will succeed if at least
80% of the pixels in the old image match the new one.
Parameters:
Name |
Type |
Description |
actual |
String
|
The path to the image generated by the emulator. (This is what goes in expect()) |
expected |
String
|
The path to the image on your system to compare with. (This is what goes in.toBeSimilarToImage()) |
Returns:
Success if the images are at least 80% similar, otherwise failure and an error message.
Example
Compares two images, to verify whether they are at least 80% similar.
// Take a screenshot of the intro screen
const testImage = await emulator.takeScreenshot('intro-screen.png');
// Do a comparison that they're similar (at least 80% the same)
expect(testImage).toBeSimilarToImage('./data/intro-screenshot.png');