Skip to content

Commit

Permalink
Replaced jest with mocha and nyc
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbjensen committed Jan 6, 2025
1 parent fe9bfcb commit 167cc4a
Show file tree
Hide file tree
Showing 11 changed files with 1,655 additions and 9,039 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
coverage
coverage
.nyc_output
5 changes: 3 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# TODO List

- [ ] Replace jest with Mocha
- [ ] Use NYC for Code coverage
- [x] Replace jest with Mocha
- [x] Use NYC for Code coverage
- [ ] Make note why `__tests__` folder is used rather than `test`, as unit tests would delete `test` folder for mcg.bin.js
- [ ] Convert the codebase to TypeScript
- [ ] Setup the codebase to publish NPM versions automatically
8 changes: 4 additions & 4 deletions __tests__/bin/mcg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,12 @@ describe('mcg', () => {
});

describe('with attributes passed', () => {
it.todo(
it(
'should generate a migration file that specifies what fields to put in the model table'
);
it.todo('should generate a model file with a jsonSchema property');
it.todo('should define properties for the test seed data file');
it.todo(
it('should generate a model file with a jsonSchema property');
it('should define properties for the test seed data file');
it(
'should define things to test in the model test file, such as validations'
);
});
Expand Down
2 changes: 1 addition & 1 deletion __tests__/data/testModelFileExample.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ const Post = require('../../models/Post');

describe('Post', () => {
Post;
it.todo('should do something');
it('should do something');
});
4 changes: 2 additions & 2 deletions __tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ const {

describe('main', () => {
const rootDir = path.join(process.cwd(), 'testApp');
beforeAll(async () => {
before(async () => {
await mkdir(rootDir);
return await mcg('Post', rootDir);
});

afterAll(async () => {
after(async () => {
return await rmdir(rootDir, { recursive: true });
});

Expand Down
8 changes: 4 additions & 4 deletions __tests__/lib/createRequiredFiles.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ describe('createRequiredFiles', () => {
const modelName = 'Post';
const tableName = 'posts';

beforeAll(async () => {
before(async () => {
return await createFolderUnlessExists(rootDir);
});

afterAll(async () => {
after(async () => {
return await rmdir(rootDir, { recursive: true });
});

Expand Down Expand Up @@ -150,7 +150,7 @@ describe('createRequiredFiles', () => {
let expectedFiles = null;
let result = null;

beforeAll(async () => {
before(async () => {
await mkdir(anotherRootDir);
await createRequiredFolders({
rootDir: anotherRootDir,
Expand All @@ -171,7 +171,7 @@ describe('createRequiredFiles', () => {
});
});

afterAll(async () => {
after(async () => {
await rmdir(anotherRootDir, { recursive: true });
});

Expand Down
4 changes: 2 additions & 2 deletions __tests__/lib/createRequiredFolders.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ describe('createRequiredFolders', () => {
const rootDir = path.join(process.cwd(), 'thirdTestApp');
const testFolder = '__tests__';

beforeAll(async () => {
before(async () => {
await mkdir(rootDir);
await createRequiredFolders({
rootDir,
testFolder,
});
});

afterAll(async () => {
after(async () => {
await rmdir(rootDir, { recursive: true });
});

Expand Down
185 changes: 0 additions & 185 deletions jest.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion lib/templates/testModelFileTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const ${modelFileName} = require('${modelFilePath}');
describe('${modelFileName}', () => {
${modelName};
it.todo('should do something');
it('should do something');
});
`;
};
Loading

0 comments on commit 167cc4a

Please sign in to comment.