Skip to content

Instantly share code, notes, and snippets.

@jsturtevant
Created July 25, 2017 20:36
Show Gist options
  • Save jsturtevant/b6f32c8250f7ac2cd81b42157ea0d2dc to your computer and use it in GitHub Desktop.
Save jsturtevant/b6f32c8250f7ac2cd81b42157ea0d2dc to your computer and use it in GitHub Desktop.
Azure Functions VS Code debugging scripts
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Azure Functions",
"type": "node",
"request": "attach",
"port": 5858
},
{
"type": "node",
"request": "launch",
"name": "Run Tests",
"program": "${workspaceRoot}\\tests\\test-runner.js",
"args": [
"./tests" //run all the tests
]
}
]
}
var test = require('tape');
var path = require('path');
var fs = require('fs');
test.createStream().pipe(process.stdout);
var testDir = process.argv[2];
// https://stackoverflow.com/a/21459809/697126
var getAllFilesFromFolder = function(dir) {
var results = [];
fs.readdirSync(dir).forEach(function(file) {
file = dir+'/'+file;
var stat = fs.statSync(file);
if (stat && stat.isDirectory()) {
results = results.concat(getAllFilesFromFolder(file))
} else results.push(file);
});
return results;
};
var testFiles = getAllFilesFromFolder(testDir).filter(x => {return x.endsWith('.test.js')});
testFiles.forEach(file => {
console.log('running test file: ' + file);
var pathToModule = path.resolve(file);
require(pathToModule);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment