Skip to content

Commit

Permalink
Configure jest and add a test case
Browse files Browse the repository at this point in the history
  • Loading branch information
smikula committed Oct 12, 2017
1 parent fe82695 commit 32aa3be
Show file tree
Hide file tree
Showing 5 changed files with 2,503 additions and 28 deletions.
10 changes: 10 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
testEnvironment: 'node',
moduleDirectories: ['node_modules'],
moduleFileExtensions: ['ts', 'js'],
transform: {
'.ts': '<rootDir>/jest.preprocessor.js',
},
transformIgnorePatterns: ['node_modules'],
testMatch: ['<rootDir>/test/**/*Tests.ts'],
};
11 changes: 11 additions & 0 deletions jest.preprocessor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const tsc = require('typescript');
const tsConfig = require('./tsconfig.json');

module.exports = {
process(src, path) {
if (path.endsWith('.ts')) {
return tsc.transpile(src, tsConfig.compilerOptions, path, []);
}
return src;
},
};
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
"main": "lib/index.js",
"scripts": {
"build": "tsc",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest"
},
"author": "Scott Mikula <[email protected]>",
"license": "MIT",
"dependencies": {
"@types/jest": "^21.1.2",
"fs": "^0.0.1-security",
"glob": "^7.1.2",
"jest": "^21.2.1",
"minimatch": "^3.0.4",
"typescript": "~2.4.0"
},
"devDependencies": {
"@types/node": "^7.0.4"
}
}
}
7 changes: 7 additions & 0 deletions test/fileMatchesTagTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import fileMatchesTag from '../src/fileMatchesTag';

describe('fileMatchesTag', () => {
it('matches anything to *', () => {
expect(fileMatchesTag(null, '*')).toBe(true);
});
});
Loading

0 comments on commit 32aa3be

Please sign in to comment.