Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test support #38

Merged
merged 9 commits into from
May 18, 2017

Conversation

simonwalsh
Copy link
Contributor

Re: #20

Context: we want to bake in the support for unit testing in the host app, using Ava!

Steps:

  • (temp): run yarn add ava -save to the host app
  • run yarn to the tool app
  • add a folder in the host app called specs on the root
  • add tests in that folder and anything with the .js extension will get picked up by ava
  • from the host app, run yarn test and voila!

More:

  • to use custom configs in the host app, you can follow the steps here but not that the test folder will always need to be called specs
  • you can also pass flags to ava using yarn test -- --watch (using watch for example)

@simonwalsh simonwalsh requested a review from nddery May 11, 2017 18:31
@simonwalsh simonwalsh self-assigned this May 11, 2017
@simonwalsh simonwalsh changed the base branch from master to base-webpack-assets-pipeline May 11, 2017 18:31
…to feature/20-unit-test-support

# Conflicts:
#	bin/foobarify-scripts.js
#	yarn.lock
@simonwalsh
Copy link
Contributor Author

@nddery So apparently, we need to use babel to transpile the dependencies before ava can use them so I'm not done yet I guess!

@simonwalsh
Copy link
Contributor Author

Yeah... Not entirely sure how to go about that...

https://github.com/avajs/ava/blob/master/docs/recipes/babelrc.md#configuring-babel

I feel like we are trying to use Ava in a very unconventional way here...

Thoughts @nddery ?

@simonwalsh
Copy link
Contributor Author

simonwalsh commented May 11, 2017

Okay, just did some testing and the only way that I manage to have it working is by...

  1. adding all of this to the package.json of the project (might be solved when we have a proper npm package):
    "babel-cli": "^6.24.1",
    "babel-loader": "^7.0.0",
    "babel-preset-env": "^1.4.0",
    "babel-register": "^6.24.1",
  1. adding this line at the top of every test (before what needs to be transpiled):
import 'babel-register';
  1. adding a .babelrc file to the project with these settings:
{
  "presets": ["env"]
}

IMO this makes having ava configured in the tool kinda useless. I would rather give the user the opportunity to set it in their own project then.. not sure!

@nddery
Copy link
Contributor

nddery commented May 11, 2017

mmh.. not sure either.. tried a couple of things on my end but to no avail.. I don't know tbh..

@simonwalsh
Copy link
Contributor Author

I will refactor to see if we couldn't use Jest and this technique jestjs/jest#1468 (comment)

@simonwalsh simonwalsh merged commit 5132ecf into base-webpack-assets-pipeline May 18, 2017
@simonwalsh simonwalsh deleted the feature/20-unit-test-support branch May 18, 2017 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants