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

feat: async test case switch #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gijswijs
Copy link

Fixes #38

Test-jstransformer applies all tests to each method it can find,
regardless of the method being asynchronous or not. This is a problem
for tests that require a method to be asynchronous as mentioned in issue #38 .
These test cases should only be applied to the asynchronous methods. This
commit checks for the text '_async' in the folder name. If it can find it, only the
asynchronous test cases are performed. Asynchronous methods are tested
on synchronous test cases, because that way around it should work,
regardless of a method being asynchronous.

checkFunctionOutput is now asynchronous. This is done, because it is
not a given that template.fn(locals) returns a string. Hence this test
case can fail because template.fn(locals).trim() returns an error. By
wrapping it in a Promise.resolve() both the situations where
template.fn(locals) returns a string or a Promise are covered. This
is also how the jstranformer library works, so the tests now better
mimmick the behavior of the actual library.

Tets-jstransformer applies all tests to each method it can find,
regardless of the method being asynchronous or not. This is a problem
for tests that require a method to be asynchronous. These test cases
should only be applied to the asynchronous methods. This commit checks
for the text '_async' in the folder name. If it can find it, only the
asynchronous test cases are performed. Asynchronous methods are tested
on synchronous test cases, because that way around it should work,
regardless of a method being asynchronous.

`checkFunctionOutput` is now asynchronous. This is done, because it is
not a given that `template.fn(locals)` returns a string. Hence this test
case can fail because `template.fn(locals).trim()` returns an error. By
wrapping it in a `Promise.resolve()` both the situations where
`template.fn(locals)` returns a string or a Promise are covered. This
is also how the jstranformer library works, so the tests now better
mimmick the behavior of the actual library.
@ci-reporter
Copy link

ci-reporter bot commented May 28, 2020

The build is failing

✨ Good work on this PR so far! ✨ Unfortunately, the Travis CI build is failing as of 79ada17. Here's the output:

npm test
> [email protected] test /home/travis/build/jstransformers/test-jstransformer
> node test

 • simple
   ✓ transform has an output format (0ms)
   ✓ transform has input formats (0ms)
   ✓ simple.compile() (0ms)
 • multi
   ✓ transform has an output format (0ms)
   ✓ transform has input formats (0ms)
   • first-case
     ✓ multi.compile() (0ms)
   • second-case
     ✓ multi.compile() (0ms)
 • render
   ✓ transform has an output format (0ms)
   ✓ transform has input formats (0ms)
   ✓ render.render() (0ms)
 • renderAsync
   ✓ transform has an output format (0ms)
   ✓ transform has input formats (0ms)
   ✓ renderAsync.renderAsync() (4ms)
 • renderFile
   ✓ transform has an output format (0ms)
   ✓ transform has input formats (0ms)
   ✓ renderFile.renderFile() (0ms)
 • renderFileAsync
   ✓ transform has an output format (0ms)
   ✓ transform has input formats (0ms)
   ✓ renderFileAsync.renderFileAsync() (0ms)
 • failures
failures/reject-render-async.js
   ✓ reject-render-async.js (114ms)

Total duration 140ms
tests passed

> [email protected] posttest /home/travis/build/jstransformers/test-jstransformer
> xo --space=2 index.js


  index.js:78:13
  ✖   78:13  result is never reassigned. Use const instead.                         prefer-const
  ✖   78:98  Missing semicolon.                                                     semi
  ✖   89:13  result is never reassigned. Use const instead.                         prefer-const
  ✖   89:95  Missing semicolon.                                                     semi
  ✖   89:95  Trailing spaces not allowed.                                           no-trailing-spaces
  ✖  109:30  Use .includes(), rather than .indexOf(), when checking for existence.  unicorn/prefer-includes
  ✖  109:48  Strings must use singlequote.                                          quotes
  ✖  124:34  Use .includes(), rather than .indexOf(), when checking for existence.  unicorn/prefer-includes
  ✖  124:52  Strings must use singlequote.                                          quotes
  ✖  139:29  Use .includes(), rather than .indexOf(), when checking for existence.  unicorn/prefer-includes
  ✖  139:47  Strings must use singlequote.                                          quotes
  ✖  154:33  Use .includes(), rather than .indexOf(), when checking for existence.  unicorn/prefer-includes
  ✖  154:51  Strings must use singlequote.                                          quotes

  13 errors

I'm sure you can fix it! If you need help, don't hesitate to ask a maintainer of the project!


This comment was automagically generated by ci-reporter. If you see a problem, open an issue here.

@gijswijs gijswijs changed the title Add async test case switch feat: async test case switch May 28, 2020
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.

Mark test case as async to exclude sync methods from being tested
1 participant