Availity / availity-workflow

Upgradable workflow for Availity boilerplate projects
https://availity.github.io/availity-workflow
MIT License
28 stars 16 forks source link

test for scaffolding #194

Open robmcguinness opened 5 years ago

robmcguinness commented 5 years ago

Write a unit test that runs the cli command for scaffolding projects and test to ensure artifacts are installed properly.

MichaelDimmitt commented 5 years ago

Hi rob; Not sure if there is already a framework for scaffolding @availity/workflow

However, using Jest,

I Wrote an integration test that scaffolds the cli. After the cli is scaffolded you have the ability to unit test the project however you want.

test_results

Unfortunately it takes 1min 35 seconds to scaffold the cli on my local computer. However, once the project is scaffolded unit tests after that bottleneck will run quickly.

I am looking for alternative ideas or other cli's that have a better solution.

The test suite uses child_process {exec} and can be found at: https://github.com/MichaelDimmitt/simp-js_term/blob/master/terminal.test.js

Used jest because it seemed to agree with the javascript in the project. However, another candidate test suite for the cli commands would be a bash test suite "bats" https://opensource.com/article/19/2/testing-bash-bats

Next I am going to look at create-react-app to see how they attack the test.

Feedback appreciated.

MichaelDimmitt commented 5 years ago

https://github.com/facebook/create-react-app/blob/master/test/fixtures/__shared__/test-setup.js

Here is how create react app does their Setup and creates their CLI. It looks like create-react-app uses a util for setup that takes a template and runs yarnpkg install. https://github.com/facebook/create-react-app/blob/master/test/fixtures/__shared__/util/setup.js#L54

create-react-app uses execa ... "a better child_process"

MichaelDimmitt commented 5 years ago

@robmcguinness, are these comments heading in the right direction?

The example is an integration test that allows unit tests after the project is scaffolded.

Using Jest test suite, each test does wait on the previous test to finish. my example that scaffolds availity workflow: https://github.com/MichaelDimmitt/simp-js_term/blob/master/terminal.test.js#L31

I did not open a pr because I need to research how to ignore the test when normally running the test suite since the scaffold test takes 1minute 40seconds to run.

I think it would be a good test for the travis-ci but not necessarily for developers running the test suite before every commit.

robmcguinness commented 5 years ago

@MichaelDimmitt sorry haven't to time fully review. Quick pass of code looks good. Appreciate the research but I'll need a little more time to review.