Skip to content

Instantly share code, notes, and snippets.

@davidgilbertson
Created January 14, 2018 05:57
Show Gist options
  • Save davidgilbertson/d0c95fbfbbd447d9c52038ea585ad9da to your computer and use it in GitHub Desktop.
Save davidgilbertson/d0c95fbfbbd447d9c52038ea585ad9da to your computer and use it in GitHub Desktop.
const fs = require('fs');
const path = require('path');
const { JSDOM } = require('jsdom');
it('should not contain any external scripts, ask David why', () => {
const creditCardForm = fs.readFileSync(path.resolve(__dirname, '../public/credit-card-form.html'), 'utf8');
const dom = new JSDOM(
creditCardForm,
{ runScripts: 'dangerously' },
);
const scriptElementWithSource = dom.window.document.querySelector('script[src]');
expect(scriptElementWithSource).toBe(null);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment