Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gpsarkar/e764317af27e9a4e50ae51546fec01f7 to your computer and use it in GitHub Desktop.
Save gpsarkar/e764317af27e9a4e50ae51546fec01f7 to your computer and use it in GitHub Desktop.
testcafe snippet for asserting a text contains in pptx file
import { Selector } from 'testcafe';
var textract = require('textract');
fixture `File read and assert`
.page(about:blank);
test('test file content', async t => {
const fullFilePath = 'c:\\temp\\test.pptx';
const stringToSearch = 'ABCDXYZ1234';
var containsText = await new Promise(resolve => {
textract.fromFileWithPath(fullFilePath, function( error, text ) {
if(text.includes(stringToSearch)) {
resolve(true);
} else {
resolve(false);
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment