Skip to content

Commit 5a4023b

Browse files
committed
refactor out js features into js-coderoad package
1 parent fdb7a93 commit 5a4023b

File tree

7 files changed

+8
-84
lines changed

7 files changed

+8
-84
lines changed

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
snippets.cson
22
test
3+
src
34
src/typings
45
tsconfig.json
56
tslint.json

CHANGELOG.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5-
## [0.10.0] - 2016-08-08
5+
## [0.10.0] - 2016-08-14
66
- break test runner into two parts:
77
- load - called when a new page is set, prepares a test file
88
- run - called on test run, compiles the test file with user code
9-
- use modified "rewire" for running tests on globals
10-
- handle `import`/`export` using "babel-plugin-transform-es2015-modules-commonjs"
11-
- capture imports and globals for testing using `rewire-coderoad`
9+
- create ["js-coderoad"](https://github.com/coderoad/js-coderoad) package for js specific test features
1210

1311
## [0.9.3] - 2016-08-01
1412
- add "exists" global file path checker

lib/writeTests/index.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
"use strict";
22
var fs = require('fs');
33
var path_1 = require('path');
4-
var process_console_log_1 = require('process-console-log');
5-
var import_paths_1 = require('./import-paths');
6-
var helpers_1 = require('./helpers');
4+
var js_coderoad_1 = require('js-coderoad');
75
var tmpPath = path_1.join(__dirname, '..', '..', '.tmp');
86
function writeTest(_a) {
97
var dir = _a.dir, tests = _a.tests, testPath = _a.testPath;
10-
var output = "(function(){\n"
11-
.concat(process_console_log_1.logger)
12-
.concat(helpers_1.default(dir))
13-
.concat(import_paths_1.default(dir, tests))
14-
.concat('\n}());');
8+
var output = js_coderoad_1.default({ dir: dir, content: tests });
159
writeTestFile(testPath, output);
1610
}
1711
Object.defineProperty(exports, "__esModule", { value: true });

package.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,9 @@
2626
"test": "echo \"Error: no test specified\" && exit 1"
2727
},
2828
"dependencies": {
29-
"babel-plugin-transform-es2015-modules-commonjs": "6.11.5",
30-
"babel-register": "6.11.6",
3129
"mocha": "3.0.2",
3230
"node-file-exists": "1.1.0",
33-
"process-console-log": "0.2.3",
34-
"rewire-coderoad": "3.1.1"
31+
"js-coderoad": "0.1.0"
3532
},
3633
"devDependencies": {
3734
"chai": "3.5.0",

src/writeTests/helpers.ts

-14
This file was deleted.

src/writeTests/import-paths.ts

-41
This file was deleted.

src/writeTests/index.ts

+2-13
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
11
import * as fs from 'fs';
22
import { join } from 'path';
3-
import { logger } from 'process-console-log';
4-
import importPaths from './import-paths';
5-
import helpers from './helpers';
3+
import jsCodeRoad from 'js-coderoad';
64

75
// store compiled tests in mocha-coderoad/.tmp
86
const tmpPath = join(__dirname, '..', '..', '.tmp');
97

108
export default function writeTest({ dir, tests, testPath }) {
119

12-
const output = `(function(){\n`
13-
// append logger for capturing log values and types
14-
.concat(logger)
15-
// 1. babel hook to handle import / export in other files
16-
// 2. exists polyfill for file/folder exists checks
17-
// 3. allow access to module globals
18-
.concat(helpers(dir))
19-
// fix import paths relative to project dir instead of test runner
20-
.concat(importPaths(dir, tests))
21-
.concat('\n}());');
10+
const output = jsCodeRoad({dir, content: tests});
2211

2312
writeTestFile(testPath, output);
2413
}

0 commit comments

Comments
 (0)