Skip to content

Commit 87f7dcb

Browse files
author
yashpandit
committed
Add task for test dependency
1 parent ee12db7 commit 87f7dcb

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

generator.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = app => {
99

1010
app.use(require('generate-project'));
1111
app.register('create-react-app', require('./lib/generators/create-react-app'));
12+
app.register('custom-test', require('./lib/generators/custom-tests'));
1213

1314
/**
1415
* Generate a `index.js` file to the current working directory. Learn how to [customize

lib/generators/custom-tests.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const spawn = require('../spawn');
2+
const path = require('path');
3+
const { prompt } = require('enquirer');
4+
const { YARN, ENZYME, JEST, ADD } = require('../constants');
5+
6+
module.exports = app => {
7+
app.task('custom-test', async () => {
8+
const answers = prompt({
9+
type: 'select',
10+
name: 'test',
11+
message:
12+
'React provides a built-in testing suite. Would you like to add any of the following testing frameworks?',
13+
choices: ['Enzyme', 'Jest', 'No']
14+
});
15+
const { test } = await answers;
16+
if (test !== 'No' && test === 'Enzyme') {
17+
await spawn(YARN, [ADD, ENZYME]);
18+
} else if (test !== 'No' && test === 'Jest') {
19+
await spawn(YARN, [ADD, JEST]);
20+
}
21+
});
22+
23+
app.task('default', ['custom-test']);
24+
};

0 commit comments

Comments
 (0)