Skip to content

Instantly share code, notes, and snippets.

@nottyo
Created April 14, 2022 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nottyo/36d121c1b1bb7fbcfedea50616b10d56 to your computer and use it in GitHub Desktop.
Save nottyo/36d121c1b1bb7fbcfedea50616b10d56 to your computer and use it in GitHub Desktop.
cypress - qrcode reader
describe('QR Code', () => {
it('can read qrcode', () => {
cy.visit('./qrcode.html');
cy.get('[data-testid="qr-code-img"]')
.then($el => {
const img = $el[0];
const image = new Image();
image.width = img.width;
image.height = img.height;
image.src = img.src;
image.crossOrigin = 'Anonymous';
return image;
})
.then(image => {
const reader = new BrowserMultiFormatReader();
return reader.decodeFromImageElement(image[0])
})
.then(result => {
expect(result.getText()).to.equal('https://www.cypress.io');
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment