Skip to content

Commit

Permalink
feat: add jest setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Rickard Natt och Dag committed Nov 16, 2020
1 parent e74f5f2 commit 74bfe84
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/commands/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,16 @@ pub fn prettier() -> Result<()> {

Ok(())
}

pub fn jest() -> Result<()> {
helpers::install_dev("jest");
helpers::install_dev("jest-watch-typeahead");

template::render(
include_str!("../templates/jest.config.js"),
"jest.config.js",
None,
)?;

Ok(())
}
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ enum AddCommand {
Git,
/// Add Husky setup
Husky,
/// Add Jest setup with typeahead
Jest,
/// Add nvmrc with current node version
Nvm,
/// Add Prettier
Expand All @@ -37,6 +39,7 @@ fn main() -> Result<()> {
match opt {
Cli::Add(AddCommand::Git) => add::git()?,
Cli::Add(AddCommand::Husky) => add::husky()?,
Cli::Add(AddCommand::Jest) => add::jest()?,
Cli::Add(AddCommand::Nvm) => add::nvm()?,
Cli::Add(AddCommand::Prettier) => add::prettier()?,
Cli::GithubActions { no_npm } => github_actions::run(no_npm)?,
Expand Down
7 changes: 7 additions & 0 deletions src/templates/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
testEnvironment: 'node',
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname',
],
}

0 comments on commit 74bfe84

Please sign in to comment.