MCPcopy Index your code
hub / github.com/MALSync/MALSync / initTestsArray

Function initTestsArray

test/headless/test.js:580–631  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

578}
579
580async function initTestsArray() {
581 new Promise((resolve, reject) => {
582 dir.readFiles(
583 `${__dirname}/../../src/`,
584 {
585 match: /^tests.json$/,
586 },
587 (err, content, file, next) => {
588 if (err) throw err;
589 if (changedFiles && changedFiles.length) {
590
591 const found = changedFiles.find(
592 changed => {
593 const cleanChanged = changed.replace(/[^\/]+\.(less|ts|json)$/, '');
594 const cleanFile = file.replace('tests.json', '').replace(/\\/g, '/')
595
596 return (
597 changed &&
598 cleanChanged &&
599 cleanChanged !== 'src/' &&
600 cleanChanged !== 'src/pages/' &&
601 cleanChanged !== 'src/pages-chibi/' &&
602 cleanFile.includes(cleanChanged)
603 );
604 }
605
606 );
607
608 if (!found) {
609 next();
610 return;
611 }
612 }
613 try {
614 eval(`var s = ${content.replace(/^[^{]*/g, '')}`);
615 s.path = file;
616 testsArray.push(s);
617 } catch (e) {
618 console.log(content);
619 throw e;
620 }
621
622 next();
623 },
624 (err, files) => {
625 if (err) throw err;
626 console.log('Test files:', testsArray.map(t => t.path));
627 resolve();
628 },
629 );
630 });
631}
632
633async function resetOnline(path) {
634 fs.readFile(path, 'utf8', function(err, data) {

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected