From c6f95e4870145e32dea80871039b934f914da8d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6nnemann?= Date: Thu, 9 Jul 2015 01:45:40 +0200 Subject: [PATCH] test(pre): initial cli/integration suite --- package.json | 11 +++--- test/scenarios/pre.js | 89 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 test/scenarios/pre.js diff --git a/package.json b/package.json index 231f1062..4a1cdc1f 100644 --- a/package.json +++ b/package.json @@ -29,12 +29,12 @@ "mkdirp": "^0.5.1", "nixt": "^0.4.1", "nock": "^2.5.0", - "nyc": "^2.3.0", "npm-registry-couchapp": "^2.6.11", + "nyc": "^3.0.0", "proxyquire": "^1.5.0", "rimraf": "^2.4.0", "standard": "^4.2.1", - "tap": "^1.2.0" + "tap": "^1.3.1" }, "homepage": "https://github.com/semantic-release/core#readme", "keywords": [ @@ -59,9 +59,10 @@ "build:tests": "rimraf .test && mkdirp .test && babel test --out-dir .test", "coverage": "nyc report", "coverage:upload": "npm run coverage -- --reporter=lcovonly && coveralls < coverage/lcov.info", - "pretest:suite": "npm run build && npm run build:tests", - "test": "npm run test:style && npm run test:suite", + "pretest:unit": "npm run build && npm run build:tests", + "test": "npm run test:style && npm run test:unit && npm run test:integration", + "test:integration": "tap --no-cov .test/scenarios/*.js", "test:style": "standard", - "test:suite": "nyc tap --no-cov .test/{scenarios,specs}/*.js" + "test:unit": "nyc tap --no-cov .test/specs/*.js" } } diff --git a/test/scenarios/pre.js b/test/scenarios/pre.js new file mode 100644 index 00000000..6c5d1ba7 --- /dev/null +++ b/test/scenarios/pre.js @@ -0,0 +1,89 @@ +const { join } = require('path') + +const { test, tearDown } = require('tap') +const rimraf = require('rimraf') + +const registry = require('../registry') +const testModule = require('../lib/test-module') +const baseScenario = require('../lib/base-scenario') + +test('change version', (t) => { + t.plan(7) + + registry.start((err) => { + t.error(err, 'registry started') + if (err) t.bailout('registry not started') + + testModule('change-version', (err, cwd) => { + t.error(err, 'test-module created') + if (err) t.bailout('test-module not created') + + t.test('no version', (tt) => { + tt.plan(1) + + baseScenario(cwd, registry.uri) + .run('node ../../../bin/semantic-release.js pre') + .stderr(/ENOCHANGE/) + .code(1) + .end(tt.error) + }) + + t.test('initial version', (tt) => { + tt.plan(1) + + baseScenario(cwd, registry.uri) + .exec('git commit -m "feat: initial" --allow-empty') + .exec('node ../../../bin/semantic-release.js pre') + .run('npm publish') + .stdout(/1\.0\.0/) + .code(0) + .end(tt.error) + }) + + t.test('patch version', (tt) => { + tt.plan(1) + + baseScenario(cwd, registry.uri) + .exec('git commit -m "fix: foo" --allow-empty') + .exec('node ../../../bin/semantic-release.js pre') + .run('npm publish') + .stdout(/1\.0\.1/) + .code(0) + .end(tt.error) + }) + + t.test('feature version', (tt) => { + tt.plan(1) + + baseScenario(cwd, registry.uri) + .exec('git commit -m "feat: foo" --allow-empty') + .exec('node ../../../bin/semantic-release.js pre') + .run('npm publish') + .code(0) + .stdout(/1\.1\.0/) + .end(tt.error) + }) + + t.test('breaking version', (tt) => { + tt.plan(1) + + baseScenario(cwd, registry.uri) + .exec('git commit -m "feat: foo\n\n BREAKING CHANGE: bar" --allow-empty') + .exec('node ../../../bin/semantic-release.js pre') + .run('npm publish') + .code(0) + .stdout(/2\.0\.0/) + .end(tt.error) + }) + }) + }) +}) + +tearDown(() => { + function cb (err) { + if (err) console.log(err) + } + + rimraf(join(__dirname, '../tmp'), cb) + registry.stop(cb) +})