const fsUtil = require('fs')
const pathUtil = require('path')
// Create our suite, that will read the directory, and add tests for file
suite(`all files within ${dir} contain the word test`, function (suite, test, complete) {
// Make the file tests occur in parallel to save time
this.setConfig({concurrency: 0})
// Add the file tests by reading the directory
fs.readdir(dir, function (err, _files) {
// Abort the test if there was an error
if ( err ) return complete(err)
// Add the tests for each file
files.forEach(function (file) {
const path = pathUtil.join(dir, file)
// Add the test for reading and checking the file
test(`checking ${file}`, function (complete) {
fs.readFile(path, function (err, data) {
if ( err ) return complete(err)
if ( data.toString().indexOf('test') === -1 ) {
return complete(new Error('could not find the word test'))
// Directory has been read, tests have been added, signal our initialisation is complete
// so that the items within our suite can be run