diff --git a/bin/micro-start b/bin/micro-start index 575a674..72fc1bf 100755 --- a/bin/micro-start +++ b/bin/micro-start @@ -23,10 +23,10 @@ const complete = () => { spinner.succeed('Built!') console.log(` Next steps: - ${chalk.magenta(`cd ${name}`)} - ${chalk.magenta('yarn init')} - ${chalk.magenta('yarn')} - ${chalk.magenta('git init')} + ${chalk.magenta(`> cd ${name}`)} + ${chalk.magenta('> yarn init')} + ${chalk.magenta('> yarn')} + ${chalk.magenta('> git init')} Happy microservicing! 👌`) } diff --git a/build/index.js b/build/index.js index a48cffa..c7b7d39 100644 --- a/build/index.js +++ b/build/index.js @@ -31,13 +31,6 @@ if (WATCH) { runner = run() } }) - - process.once('SIGINT', () => { - log() - log(chalk.yellow('👋 Goodbye')) - if (runner) runner.once('exit', process.exit) - else process.exit() - }) } else { const starter = ora('Building...').start() webpack(config).run(() => { diff --git a/package.app.json b/package.app.json index c3b6cf1..eba1646 100644 --- a/package.app.json +++ b/package.app.json @@ -9,7 +9,7 @@ "micro": "^6.1.0" }, "devDependencies": { - "ava": "^0.17.0", + "babel-jest": "^19.0.0", "babel-core": "^6.21.0", "babel-loader": "^6.2.10", "babel-polyfill": "^6.20.0", @@ -17,6 +17,7 @@ "babel-register": "^6.18.0", "chalk": "^1.1.3", "eslint-config-samtgarson": "^0.0.2", + "jest": "^19.0.2", "nodemon": "^1.11.0", "ora": "^1.1.0", "request": "^2.79.0", @@ -30,8 +31,8 @@ "start": "node .", "dev": "node build --watch", "build": "node build", - "test": "ava && xo", - "test:spec": "ava", + "test": "jest && xo", + "test:spec": "jest", "test:lint": "xo" }, "xo": { @@ -58,17 +59,16 @@ "stage-2" ] }, - "ava": { - "files": [ - "test/**/*.test.js" - ], - "source": [ - "src/**/*.js" - ], - "require": [ - "babel-register", - "babel-polyfill" + "jest": { + "moduleFileExtensions": ["js"], + "transform": { + "^.+\\.js$": "/node_modules/babel-jest" + }, + "setupFiles": [ + "/test/setup.js" ], - "babel": "inherit" + "testMatch": [ + "/test/**/*.test.js" + ] } } diff --git a/package.json b/package.json index ec7f2cc..72c1eaa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "micro-starter", - "version": "0.0.4", + "version": "0.1.0", "description": "Start your micro app", "main": "index.js", "repository": "samtgarson/micro-starter", diff --git a/readme.md b/readme.md index 8691687..684b62b 100644 --- a/readme.md +++ b/readme.md @@ -9,7 +9,7 @@ Basic starter kit for a Node microservice using [Micro](https://github.com/zeit/ - 🔷 [Micro](https://github.com/zeit/micro) for no fluff HTTP serving - 📦 [Webpack](https://webpack.github.io/) for bundling with ES7 syntax -- 🚀 [AVA](https://github.com/avajs/ava) for speedy and easy to write tests +- 🃏 [Jest](https://github.com/facebook/jest) for speedy and easy to write tests - ❤️ [XO](https://github.com/sindresorhus/xo) for no fuss linting - 🤓 Development setup including file watching and server restarting for happy devs @@ -30,7 +30,7 @@ micro-start my-app-name # create a new project directory ready for microservicin ### Testing -- `yarn test:spec`: Run tests with AVA +- `yarn test:spec`: Run tests with Jest - `yarn test:lint`: Lint your code with XO - `yarn test`: Run it all diff --git a/test/main.test.js b/test/main.test.js index d211dd8..277cdaa 100644 --- a/test/main.test.js +++ b/test/main.test.js @@ -1,15 +1,20 @@ -import test from 'ava' import listen from 'test-listen' -import request from 'request-promise' +import get from 'request-promise' import srv from '../src/main' let url -test.before(async () => { +beforeEach(async () => { url = await listen(srv) }) -test('hello world', async (t) => { - const body = await request(url) - const expected = 'hello world!' - t.is(body, expected) +afterEach(async () => { + await srv.close() +}) + +describe('the app', () => { + it('responds correctly', async () => { + const body = await get(url) + const expected = 'hello world!' + expect(body).toBe(expected) + }) }) diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..2371f78 --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +require('babel-polyfill')