Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Commit

Permalink
test: update sample execution
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Apr 15, 2021
1 parent 880b35b commit 4d10749
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions test/samples.coffee
@@ -1,15 +1,19 @@

fs = require('fs').promises
util = require 'util'
path = require 'path'
{exec} = require 'child_process'
each = require 'each'

it 'samples', ->

# `describe` label doesnt print because the code inside calling `it` is asynchronous.
# From Mocha.js doc
# https://mochajs.org/#dynamically-generating-tests
# With top-level await you can collect your test data in a dynamic and asynchronous way while the test file is being loaded

describe 'Samples', ->

dir = path.resolve __dirname, '../samples'
samples = await fs.readdir dir
return each samples.filter( (sample) -> /\.js$/.test sample)
.call (sample, callback) ->
for sample in samples
continue unless /\.js$/.test sample
it "Sample #{sample}", (callback) ->
exec "node #{path.resolve dir, sample}", (err) ->
callback err
.promise()

0 comments on commit 4d10749

Please sign in to comment.