diff --git a/test/reporter.js b/test/reporter.js index 1828f9bb..8cea1d95 100644 --- a/test/reporter.js +++ b/test/reporter.js @@ -40,11 +40,11 @@ class MyReporter { `| OPTIONAL: Questions in HTML | - |`, `\x1b[0m` ); - console.log( - `\x1b[32m`, - `| Use of let/const, no use of var | - |`, - `\x1b[0m` - ); + // console.log( + // `\x1b[32m`, + // `| Use of let/const, no use of var | - |`, + // `\x1b[0m` + // ); console.log( `\x1b[32m`, `| Runs in browser without console errors | yes |`, @@ -63,4 +63,4 @@ class MyReporter { } } -module.exports = MyReporter; \ No newline at end of file +module.exports = MyReporter; diff --git a/test/test.js b/test/test.js index b720bef9..8e4538fb 100644 --- a/test/test.js +++ b/test/test.js @@ -2,6 +2,7 @@ * We have to do a bit of work upfront to allow the tests * to run in the browser and in Node.js. */ +const JSFILE = '../assignment/scripts/aboutMe.js' let assert, expect; let testItems = {}; if (typeof window === 'object') { @@ -31,13 +32,38 @@ if (typeof window === 'object') { // Run tests in Node.js assert = require('assert'); expect = require('chai').expect; - testItems = require('../assignment/scripts/aboutMe.js'); + testItems = require(JSFILE); } /** * Put all tests within this describe. */ describe('Automated tests', function () { + describe('Using let and const, not var', function () { + it(`Using let and const, not var`, function () { + + if (typeof window !== 'undefined') { + this.skip(); // Skip this test if running in a browser + } + + const fs = require('fs'); + const path = require('path') + // Read the file + const data = fs.readFileSync(path.resolve(__dirname, JSFILE), 'utf8') + + + // Define the regex pattern + const regex = /var\s/g; + + // Find all matches + const matches = data.match(regex); + + expect(matches.length).to.equal(0); + + }) + }); + + }) describe(`First Name assigned to String`, function () { it(`First Name assigned to String`, function () { let { firstName } = testItems;