checkImage method

Class: EyesPlatform: ImagesLanguage: JavaScript SDK:

Run a checkpoint on an image that you provide as a parameter.

Syntax


let result = await eyes.checkImage(base64String, name, ignoreMismatch);

let result = await eyes.checkImage(base64String, name);

let result = await eyes.checkImage(base64String);

let result = await eyes.checkImage(url, name, ignoreMismatch);

let result = await eyes.checkImage(url, name);

let result = await eyes.checkImage(url);

let result = await eyes.checkImage(filePath, name, ignoreMismatch);

let result = await eyes.checkImage(filePath, name);

let result = await eyes.checkImage(filePath);

let result = await eyes.checkImage(imageBuffer, name, ignoreMismatch);

let result = await eyes.checkImage(imageBuffer, name);

let result = await eyes.checkImage(imageBuffer);

Parameters

base64String
Type:string
The checkpoint image in PNG format, encoded in base64.
name
Type:string [Optional ]

The tag defines a name for the checkpoint in the Eyes Test Manager. The name may be any string and serves to identify the step to the user in the Test manager. You may change the tag value without impacting testing in any way since Eyes does not use the tag to identify the baseline step that corresponds to the checkpoint - Eyes matches steps based on their content and position in the sequences of images of the test. See How Eyes compares checkpoints and baseline images for details.

ignoreMismatch
Type:boolean [Optional ]
This parameter is used to implement retry of a checkpoint. If you are not implementing retry, then don't pass this parameter or pass a value of false. To implement retry, on all retry attempts apart from the last, pass this parameter a value of true. When the method returns, check the return value. A returned value of true means that the checkpoint passed, and you can continue with the next checkpoint. A returned value of false means that that the checkpoint did not match. Since this parameter was passed as true, Eyes will not store the outcome of this checkpoint and will expect that the next image sent is for the current step (i.e. is being retried). On the last retry attempt, pass a value of false. This way, Eyes knows that there will be no more retries, and it will store the results of the last check as the result of the current step. The next checkpoint sent will be treated as the next step. Note that since Eyes allows for new or deleted steps, once there is a mismatch for one step, all subsequent steps will also return a mismatch, and Eyes determines the actual match/mismatch/new/missing status of all the steps when the test is closed.
url
Type:string
A string with the URL of the checkpoint image. The image must be in PNG format.
filePath
Type:string
A string with the file system path to the checkpoint image file. The image must be in PNG format.
imageBuffer
Type:Buffer
The checkpoint image as an object in PNG format.

Return value

Type: Promise<boolean>
A return value of true indicates that the checkpoint matched, or is a new checkpoint. The meaning of a return value of false depends on whether this is the first checkpoint to return this value or not. For the first checkpoint that returns a value of false, the implication is that there was a mismatch. The test may choose to recapture the image and resend it (when using a check that supports this feature). Once one checkpoint has returned false, all the following checkpoints will also return false. This does not mean that the checkpoint mismatched; it means that Eyes will only know the final status of the checkpoint at the end of the test. If required, the actual result of the checkpoint should be obtained from the StepInfo object in the TestResults returned by the close method.

Remarks

This method can take three different types of string: a base64 image, a URL, and a file path. It inspects the format of the data to decide if what it has is an image, a URL, or a filepath.