Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions test/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 |`,
Expand All @@ -63,4 +63,4 @@ class MyReporter {
}
}

module.exports = MyReporter;
module.exports = MyReporter;
28 changes: 27 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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;
Expand Down