Skip to content

Commit

Permalink
Chore: adds tests for packing process
Browse files Browse the repository at this point in the history
  • Loading branch information
pustovitDmytro committed Apr 15, 2021
1 parent 0b6e984 commit 9b9602d
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ lib/*
coverage/*
tmp/*
logs/*
*.log
*.log
*.tgz
9 changes: 8 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ tests
.eslintrc
.eslintignore
.babelrc
tmp
tmp
.husky
bin
*.tgz
.commitlintrc.json
.mocharc.json
.nycrc.json
.releaserc.json
7 changes: 7 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
"assets": ["README.md", "CHANGELOG.md", "package.json"],
"message": "Chore(release): add version ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
[
"@semantic-release/github", {
"assets": [
{ "path": "*.tgz" }
]
}
]
],
"preset": "eslint",
Expand Down
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ jobs:
script: "npm run test:coverage"
- stage: test
script: "npm run test:security"
- stage: test
script: "npm run test:package"
- stage: release
node_js: lts/*
deploy:
provider: script
skip_cleanup: true
script:
- ./bin/pack.sh
- npx semantic-release
notifications:
email:
Expand Down
5 changes: 5 additions & 0 deletions bin/pack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
rm -rf tmp/package
PACKAGE="$(npm pack 2>&1 | tail -1)"
mkdir -p tmp
tar -xvzf $PACKAGE -C tmp
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
"test:security": "npm audit",
"test:lint": "eslint src",
"test:mocha": "mocha --config .mocharc.json tests/**/*test.js",
"test:package": "./bin/pack.sh && ENTRY=./tmp/package/lib npm run test:mocha",
"test:coverage": "BUILD=0 MODE=test nyc mocha --config .mocharc.json tests/**/*test.js",
"coverage-check": "MODE=test nyc check-coverage",
"test": "npm run test:lint && npm run test:security && npm run test:coverage",
"test": "npm run test:lint && npm run test:security && BUILD=1 npm run test:mocha",
"semantic-release": "semantic-release"
},
"repository": {
Expand Down Expand Up @@ -40,6 +41,7 @@
"@semantic-release/changelog": "^3.0.4",
"@semantic-release/commit-analyzer": "^6.1.0",
"@semantic-release/git": "^7.0.8",
"@semantic-release/github": "^7.2.1",
"@semantic-release/npm": "^5.1.7",
"@semantic-release/release-notes-generator": "^7.1.4",
"babel-eslint": "^10.0.1",
Expand Down
9 changes: 6 additions & 3 deletions tests/entry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module.exports = process.env.BUILD !== '0'
? require('../lib')
: require('../src');
import path from 'path';

const isBuild = process.env.BUILD && [ '1', 'true' ].includes(process.env.BUILD);
const entry = process.env.ENTRY && path.resolve(process.env.ENTRY);

module.exports = entry && require(entry) || isBuild && require('../lib') || require('../src');

4 changes: 2 additions & 2 deletions tests/package/configurations.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { assert } from 'chai';
import logger from '../entry';
import { verifyStdout } from '../utils';
import entry from '../entry';

suite('Configurations');

test('Default configuration', function () {
assert.exists(entry);
});

0 comments on commit 9b9602d

Please sign in to comment.