import { deepEqual } from 'assert';
import { join } from 'path';
import { parse } from '../src/parser';
import { readFileSync, readdirSync, writeFileSync } from 'fs';

const examplesPath = join(__dirname, 'examples');
readdirSync(examplesPath).forEach(entry => {
  const dir = join(examplesPath, entry);
  it(entry, () => {
    const input = readFileSync(join(dir, 'input.coffee'), { encoding: 'utf8' });
    const actual = parse(input);
    writeFileSync(join(dir, '_actual.json'), JSON.stringify(actual, null, 2), { encoding: 'utf8' });
    const expected = JSON.parse(readFileSync(join(dir, 'output.json'), { encoding: 'utf8' }));
    deepEqual(actual, expected);
  });
});

@@ -161,20 +161,18 @@
  'fs';%0A%0A
-cons
+le
 t exampl
@@ -209,16 +209,17 @@
 ples');%0A
+%0A
 readdirS
@@ -257,20 +257,18 @@
  =%3E %7B%0A  
-cons
+le
 t dir = 
@@ -300,11 +300,199 @@
 ;%0A  
-it(
+let configPath = join(dir, '_config.js');%0A  let config = requireOptional(configPath) %7C%7C %7B%7D;%0A  let testFn = config.only ? it.only : config.skip ? it.skip : it;%0A%0A  testFn(config.description %7C%7C 
 entr
@@ -506,20 +506,18 @@
 %3E %7B%0A    
-cons
+le
 t input 
@@ -585,20 +585,18 @@
 %7D);%0A    
-cons
+le
 t actual
@@ -721,12 +721,10 @@
     
-cons
+le
 t ex
@@ -845,12 +845,121 @@
 ;%0A  %7D);%0A%7D);%0A
+%0Afunction requireOptional(path) %7B%0A  try %7B%0A    return require(path);%0A  %7D catch (err) %7B%0A    return null;%0A  %7D%0A%7D%0A

Allow configuring tests.