Skip to content

Instantly share code, notes, and snippets.

@AshKyd
Last active January 29, 2019 11:55
Show Gist options
  • Save AshKyd/0275db246644b1f4616abf4eea9b07cb to your computer and use it in GitHub Desktop.
Save AshKyd/0275db246644b1f4616abf4eea9b07cb to your computer and use it in GitHub Desktop.
Mocha tests: Quick script to set up mocha testing in a project.
#!/bin/bash
# Install mocha in the background
npm install mocha --save-dev
# Make test folder & add a sample test
mkdir -p test/data
curl https://gist.githubusercontent.com/AshKyd/0275db246644b1f4616abf4eea9b07cb/raw/test.js?`date +%s` > test/index.js
# Add test command to npm scripts
npx json -f package.json --in-place -e 'this.scripts.test = "mocha test/**"'
# Run the tests
npm test
const assert = require('assert');
describe('basic operation', () => {
it('should start', () => {
// do something
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment