Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Re-enable in-body error check and report messages
Browse files Browse the repository at this point in the history
  • Loading branch information
zarathustra323 committed Feb 23, 2023
1 parent 7af5c7d commit 11af55c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
25 changes: 17 additions & 8 deletions packages/marko-web/integration/test-website-boot.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
const fetch = require('node-fetch');
const { htmlEntities } = require('@parameter1/base-cms-html');

const { error, log } = console;

const url = process.env.MARKO_WEB_INTEGRATION_TEST_URL || 'http://localhost:80';

setInterval(async () => {
try {
const res = await fetch('http://localhost:80', { method: 'get' });
const res = await fetch(url, { method: 'get' });
if (!res.ok) {
error('Response not ok!', res.status, res.statusText);
process.exit(1);
} else {
const html = await res.text();
// check for in-body body errors
const matches = [...html.matchAll(/data-marko-error="(.*?)"/g)];
const errors = [];
matches.forEach((values) => {
const value = values[1];
errors.push(htmlEntities.decode(value));
});
if (errors.length) {
error('In-page, server-side Marko error(s) were encountered!', errors);
process.exit(0);
}

// if not in-body errors, ensure page rendered.
const found = /.*<\/head>.*<\/body>.*<\/html>.*/is.test(html);
if (!found) {
error('Unable to find closing HTML tags!');
process.exit(1);
return;
}
// now check for any server errors
// if (/data-marko-error="true"/g.test(html)) {
// error('An in-page server-side Marko error was encountered!');
// process.exit(1);
// return;
// }
log('Integration tests passed!');
process.exit(0);
}
Expand Down
1 change: 1 addition & 0 deletions packages/marko-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@parameter1/base-cms-embedded-media": "^4.0.2",
"@parameter1/base-cms-express-apollo": "^4.0.2",
"@parameter1/base-cms-graphql-fragment-types": "^4.0.2",
"@parameter1/base-cms-html": "^4.0.2",
"@parameter1/base-cms-image": "^4.0.2",
"@parameter1/base-cms-inflector": "^4.0.2",
"@parameter1/base-cms-marko-express": "^4.0.2",
Expand Down

0 comments on commit 11af55c

Please sign in to comment.