MCPcopy Create free account
hub / github.com/FSGModding/FSG_Mod_Assistant / tester

Function tester

test/tests/sourcehtml.js:22–69  ·  view source on GitHub ↗
(test)

Source from the content-addressed store, hash-verified

20}
21
22async function tester (test) {
23 const promiseArray = []
24 const rootPath = path.join(__dirname, '..', '..')
25
26 const thisPath = path.join(__dirname, '..', '..', 'renderer', '**', '*.html').split(path.sep).join('/')
27 const htmlFiles = globSync(thisPath, { absolute : true })
28 let errorTotal = 0
29 let errorFiles = 0
30
31 const thisValidator = new HtmlValidate({
32 extends : ['html-validate:recommended'],
33 rules : {
34 'element-name' : ['error', { whitelist : ['l10n'] }],
35 'element-required-ancestor' : 'off',
36 'element-required-attributes' : 'off',
37 'element-required-content' : 'off',
38 'empty-heading' : 'off',
39 'no-inline-style' : 'off',
40 'no-trailing-whitespace' : 'off',
41 'prefer-native-element' : ['error', { exclude : ['progressbar']}],
42 'prefer-tbody' : 'off',
43 'text-content' : 'off',
44 'valid-id' : ['error', {'relaxed' : true}],
45 },
46 })
47
48 for ( const file of htmlFiles ) {
49 const thisFile = path.relative(rootPath, file)
50 const fileContents = fs.readFileSync(file, { encoding : 'utf8' }).replace(/{{uuid}}/g, () => crypto.randomUUID())
51
52 promiseArray.push(thisValidator.validateString(fileContents).then((result) => {
53 if ( result.errorCount === 0 ) {
54 test.step(`${thisFile} is clean`)
55 } else {
56 errorFiles++
57 errorTotal += result.errorCount
58 test.error(`${thisFile} has ${result.errorCount} Errors`)
59 for ( const thisError of result.results[0].messages ) {
60 test.step_log(`${thisFile} :: [${thisError.line}] {${thisError.ruleId}} ${thisError.message}`)
61 }
62
63 }
64 }))
65 }
66 return Promise.all(promiseArray).then(() => {
67 if ( errorTotal > 0 ) { test.error(`Total Errors Found : ${errorTotal} in ${errorFiles} files`)}
68 })
69}

Callers 1

sourcehtml.jsFile · 0.70

Calls 3

stepMethod · 0.80
step_logMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected