Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Organize and restructure tests #2049

Merged
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e2d4402
chore: wrap logger tests in top-level describe
maverick1872 Jan 29, 2022
29a9ff7
chore: restructure tests directory
maverick1872 Jan 29, 2022
23d9036
chore: restructure logger tests
maverick1872 Jan 30, 2022
5df5786
chore: cleanup test descriptions
maverick1872 Jan 30, 2022
4b0624b
fix: fix ci step to account for npm script rename
maverick1872 Jan 30, 2022
d23801d
Merge branch 'master' into chore/organize-logger-tests
maverick1872 Jan 30, 2022
c942452
chore: rename tests dir back to test
maverick1872 Jan 30, 2022
e72d96b
fix: correct relative file paths
maverick1872 Jan 30, 2022
4495caa
make sure all tests actually run
maverick1872 Jan 30, 2022
f951b9a
feat: add nyc configuration file
maverick1872 Jan 30, 2022
6ba9967
chore: fix missing end of file newlines
maverick1872 Jan 30, 2022
fd14dfe
fix: ci steps
maverick1872 Jan 30, 2022
70fa754
fix: ci steps try 2
maverick1872 Jan 30, 2022
e18e1bb
chore: rename ci jobs
maverick1872 Jan 30, 2022
692de0d
chore: leverage yaml file for nyc configuration
maverick1872 Jan 31, 2022
dc005b7
chore: move nyc configuration from npm script to associated configura…
maverick1872 Jan 31, 2022
f2ee50a
chore: move common mocha configurations from npm script to dedicated …
maverick1872 Jan 31, 2022
9310703
fix: disable mocha recursive option as path glob handles accordingly
maverick1872 Jan 31, 2022
203ba00
updated mocha options
fearphage Feb 1, 2022
9b2fb38
coverage should run all tests
fearphage Feb 2, 2022
546a271
Revert "coverage should run all tests"
fearphage Feb 6, 2022
e400ec9
Merge remote-tracking branch 'upstream/master' into chore/organize-lo…
maverick1872 Feb 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: CI Checks

on:
pull_request:
Expand All @@ -11,7 +11,7 @@ on:
- master

jobs:
unit-tests:
Tests:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -28,9 +28,11 @@ jobs:
run: npm clean-install
- name: Lint
run: npm run lint
- name: Test
run: npm test
- name: Coveralls
- name: Integration Tests
run: npm run test:integration
- name: Test Coverage
run: npm run test:coverage
fearphage marked this conversation as resolved.
Show resolved Hide resolved
- name: Report test coverage to Coveralls.io
if: matrix.node == '16'
uses: coverallsapp/github-action@master
with:
Expand Down
4 changes: 4 additions & 0 deletions .mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
exclude:
- test/helpers/scripts/*.js
maverick1872 marked this conversation as resolved.
Show resolved Hide resolved
exit: true
recursive: true
8 changes: 8 additions & 0 deletions .nycrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
reporter:
- text
- lcov
check-coverage: true
branches: 61.51
lines: 70.85
functions: 73.21
statements: 70.54
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@
"types": "./index.d.ts",
"scripts": {
"lint": "populist lib/*.js lib/winston/*.js lib/winston/**/*.js",
"pretest": "npm run lint",
fearphage marked this conversation as resolved.
Show resolved Hide resolved
"test": "nyc --reporter=text --reporter lcov npm run test:mocha",
"test:mocha": "mocha test/*.test.js test/**/*.test.js --exit",
"test": "mocha",
"test:coverage": "nyc npm run test",
fearphage marked this conversation as resolved.
Show resolved Hide resolved
"test:unit": "mocha test/unit",
"test:integration": "mocha test/integration",
"build": "rimraf dist && babel lib -d dist",
"prepublishOnly": "npm run build"
},
"engines": {
"node": ">= 6.4.0"
"node": ">= 12.0.0"
},
"license": "MIT"
}
Empty file.
3 changes: 2 additions & 1 deletion test/helpers/scripts/default-exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

var path = require('path'),
winston = require('../../../lib/winston');
const testLogFixturesPath = path.join(__dirname, '..', '..', 'fixtures', 'logs');
maverick1872 marked this conversation as resolved.
Show resolved Hide resolved

winston.exceptions.handle([
new winston.transports.File({
filename: path.join(__dirname, '..', '..', 'fixtures', 'logs', 'default-exception.log'),
filename: path.join(testLogFixturesPath, 'default-exception.log'),
handleExceptions: true
})
]);
Expand Down
10 changes: 2 additions & 8 deletions test/helpers/scripts/default-rejections.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,11 @@

var path = require("path"),
winston = require("../../../lib/winston");
const testLogFixturesPath = path.join(__dirname, '..', '..', 'fixtures', 'logs');

winston.rejections.handle([
new winston.transports.File({
filename: path.join(
__dirname,
"..",
"..",
"fixtures",
"logs",
"default-rejection.log"
),
filename: path.join(testLogFixturesPath, "default-rejection.log"),
handleRejections: true
})
]);
Expand Down
3 changes: 2 additions & 1 deletion test/helpers/scripts/exit-on-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

var path = require('path'),
winston = require('../../../lib/winston');
const testLogFixturesPath = path.join(__dirname, '..', '..', 'fixtures', 'logs');

winston.exitOnError = function (err) {
process.stdout.write(err.message);
Expand All @@ -16,7 +17,7 @@ winston.exitOnError = function (err) {

winston.handleExceptions([
new winston.transports.File({
filename: path.join(__dirname, '..', 'logs', 'exit-on-error.log'),
filename: path.join(testLogFixturesPath, 'exit-on-error.log'),
handleExceptions: true
})
]);
Expand Down
3 changes: 2 additions & 1 deletion test/helpers/scripts/log-exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

var path = require('path'),
winston = require('../../../lib/winston');
const testLogFixturesPath = path.join(__dirname, '..', '..', 'fixtures', 'logs');

var logger = winston.createLogger({
transports: [
new winston.transports.File({
filename: path.join(__dirname, '..', '..', 'fixtures', 'logs', 'exception.log'),
filename: path.join(testLogFixturesPath, 'exception.log'),
handleExceptions: true
})
]
Expand Down
10 changes: 2 additions & 8 deletions test/helpers/scripts/log-rejections.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,12 @@

var path = require("path"),
winston = require("../../../lib/winston");
const testLogFixturesPath = path.join(__dirname, '..', '..', 'fixtures', 'logs');

var logger = winston.createLogger({
transports: [
new winston.transports.File({
filename: path.join(
__dirname,
"..",
"..",
"fixtures",
"logs",
"rejections.log"
),
filename: path.join(testLogFixturesPath, "rejections.log"),
handleRejections: true
})
]
Expand Down
3 changes: 2 additions & 1 deletion test/helpers/scripts/log-string-exception.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

var path = require('path'),
winston = require('../../../lib/winston');
const testLogFixturesPath = path.join(__dirname, '..', '..', 'fixtures', 'logs');

var logger = winston.createLogger({
transports: [
new winston.transports.File({
filename: path.join(__dirname, '..', '..', 'fixtures', 'logs', 'string-exception.log'),
filename: path.join(testLogFixturesPath, 'string-exception.log'),
handleExceptions: true
})
]
Expand Down
3 changes: 2 additions & 1 deletion test/helpers/scripts/unhandle-exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

var path = require('path'),
winston = require('../../../lib/winston');
const testLogFixturesPath = path.join(__dirname, '..', '..', 'fixtures', 'logs');

var logger = winston.createLogger({
transports: [
new winston.transports.File({
filename: path.join(__dirname, '..', 'logs', 'unhandle-exception.log')
filename: path.join(testLogFixturesPath, 'unhandle-exception.log')
})
]
});
Expand Down
3 changes: 2 additions & 1 deletion test/helpers/scripts/unhandle-rejections.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

var path = require('path'),
winston = require('../../../lib/winston');
const testLogFixturesPath = path.join(__dirname, '..', '..', 'fixtures', 'logs');

var logger = winston.createLogger({
transports: [
new winston.transports.File({
filename: path.join(__dirname, '..', 'logs', 'unhandle-rejections.log')
filename: path.join(testLogFixturesPath, 'unhandle-rejections.log')
})
]
});
Expand Down
4 changes: 2 additions & 2 deletions test/winston.test.js → test/integration/winston.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

const { format } = require('util');
const assume = require('assume');
const winston = require('../lib/winston');
const winston = require('../../lib/winston');

describe('winston', function () {

Expand All @@ -35,7 +35,7 @@ describe('winston', function () {
});

it('exposes version', function () {
assume(winston.version).equals(require('../package').version);
assume(winston.version).equals(require('../../package.json').version);
});

it('abstract-winston-logger');
Expand Down
Loading