@michaelsndr For your portfolio, I would not even add the test suite. There is no requirement to put the test suite into the projects outside of the projects you create for Free Code Camp. I personally would use different pages to submit to FCC for the projects just to get the certification and then polish up ant project you plan to use on your portfolio without using the test suite at all.
If you still want to use the same projects for both, then you could add something like the following to an external js file. Basically, you would add the querystring ?fcc=true
to the url you submit for your project to Free Code Camp and not use the querystring for your actual portfolio. This would make it so the test suite only shows on the project you submit to Free Code Camp.
const loadScript = (source, beforeEl, async = true, defer = true) => {
return new Promise((resolve, reject) => {
let script = document.createElement('script');
const prior = beforeEl || document.getElementsByTagName('script')[0];
script.async = async;
script.defer = defer;
function onloadHander(_, isAbort) {
if (isAbort || !script.readyState || /loaded|complete/.test(script.readyState)) {
script.onload = null;
script.onreadystatechange = null;
script = undefined;
if (isAbort) {
reject();
} else {
resolve();
}
}
}
script.onload = onloadHander;
script.onreadystatechange = onloadHander;
script.src = source;
prior.parentNode.insertBefore(script, prior);
});
}
(() => {
const query = window.location.search.substring(1);
const vars = query.split("&");
for (let param of vars) {
const [varName, val] = param.split("=");
if (varName == 'fcc' && val === 'true') {
const scriptUrl = 'https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js';
loadScript(scriptUrl).catch(() => {
console.log('failed to load test script');
});
}
}
})();