Skip to content

Commit

Permalink
Add system test for published package content
Browse files Browse the repository at this point in the history
  • Loading branch information
codenirvana committed Sep 14, 2023
1 parent 760f4f3 commit 7c3b5ee
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ Thumbs.db
*.REMOTE.*
*.orig

# Prevent unit test coverage reports from being added
# - Prevent unit test coverage reports from being committed to the repository
.coverage
.nyc_output
4 changes: 2 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Thumbs.db
# - Allow sublime text project file to be committed in the development directory.
!/develop/*.sublime-project

# - Prevent CI output files from being Added
# - Prevent CI output files from being added
/out/
/newman/

Expand All @@ -38,7 +38,7 @@ Thumbs.db
*.REMOTE.*
*.orig

# - Prevent unit test coverage reports from being added
# - Prevent code coverage reports from being added
.coverage
.nyc_output

Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ newman.run({
});
```

All events receive two arguments (1) `error` and (2) `args`. **The list below describes the properties of the second
argument object.**
All events receive two arguments (1) `error` and (2) `args`. The list below describes the properties of the second
argument object. [Learn more](https://github.com/postmanlabs/newman/wiki/Newman-Run-Events)

| Event | Description |
|-----------|---------------|
Expand All @@ -405,8 +405,6 @@ argument object.**
| beforeDone | An event that is triggered prior to the completion of the run |
| done | This event is emitted when a collection run has completed, with or without errors |

<!-- TODO: write about callback summary -->

[back to top](#table-of-contents)

## Reporters
Expand Down
23 changes: 23 additions & 0 deletions test/system/npm-publish.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const expect = require('chai').expect,
// eslint-disable-next-line security/detect-child-process
exec = require('child_process').execSync;

describe('npm publish', function () {
const stdout = exec('npm pack --dry-run --json').toString(),
packageInfo = JSON.parse(stdout.substring(stdout.indexOf('[')))[0],
packagedFiles = packageInfo.files.map(function (file) { return file.path; });

it('should have a valid package name', function () {
expect(packageInfo.name).to.equal('newman');
});

it('should not publish unnecessary files', function () {
const allowedFiles = ['index.js', 'package.json', 'LICENSE.md',
'README.md', 'CHANGELOG.yaml', 'MIGRATION.md', 'SECURITY.md'];

packagedFiles.forEach(function (path) {
expect(allowedFiles.includes(path) || path.startsWith('lib/') ||
path.startsWith('bin/') || path.startsWith('docker/')).to.be.true;
});
});
});

0 comments on commit 7c3b5ee

Please sign in to comment.