Skip to content

Add test suite #9

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

Closed
10 of 21 tasks
SleeplessByte opened this issue May 26, 2019 · 7 comments
Closed
10 of 21 tasks

Add test suite #9

SleeplessByte opened this issue May 26, 2019 · 7 comments
Assignees

Comments

@SleeplessByte
Copy link
Member

SleeplessByte commented May 26, 2019

I prefer using something like ava because it's nice for our needs (runs everything randomly and concurrently by default, and requires us to compile it first, which is the first step of the code).

We should:

  • test inputs (finding input files) and their flags
  • test outputs (that the output files are correctly created)
  • for each exercise:
    • test at least 1 optimal solution
    • try to test hitting each path

Tracking progress:

  • two-fer
    • smoke (inline each status once)
    • snapshot (0-20 fixture snapshot per status)
    • specific path tests
  • resistor-color
    • smoke (inline each status once)
    • snapshot (0-20 fixture snapshot per status)
    • specific path tests
  • resistor-color-duo
    • smoke (inline each status once)
    • snapshot (0-20 fixture snapshot per status)
    • specific path tests
  • gigasecond
    • smoke (inline each status once)
    • snapshot (0-20 fixture snapshot per status)
    • specific path tests
@tejasbubane
Copy link
Member

I have not used Typescript much, so excuse me if this is incorrect. But I feel we should stick to Jest for following reasons:

  • Jest also runs everything randomly and concurrently by default.
  • Having same tooling with the JS track repo (apart from typescript) should be better. All decisions (test, eslint rules, code-conventions, etc.) apply to both repos - less bikeshedding.
  • I hope compiling can be integrated in Jest as well (typescript-jest integration).

@SleeplessByte
Copy link
Member Author

@tejasbubane yes, I'm fine with jest for the same reasons as I'm fine with ava (hence me saying "something like ava"). I think your reasoning makes sense. We should also use jest in the typescript and typescript-analyzer repositories.

I hope compiling can be integrated in Jest as well (typescript-jest integration).

As long as we don't use ts-node I'm good with that. I'm also okay with stripping types via babel, but that has to be a decision we make (to use babel instead of the tsc to to transpilation).

@tejasbubane
Copy link
Member

tejasbubane commented May 27, 2019

Are fixtures used in any way right now? If yes where? If not whats the plan with them?

@SleeplessByte
Copy link
Member Author

Are fixtures used in any way right now? If yes where? If not whats the plan with them?

Yes, these are the first 500 submissions to the exercise on the track. They can be used locally to run:

  • batch-runner
  • statistics

I use it to manually check if the right response is generated for an analyzer:

  1. write the analyzer according to the optimal and minimal solution
  2. inspect a few random solutions
  3. make sure the analyzer works with that
  4. run batch (all of them)
  5. inspect at least 20 random exercises
  6. repeat

The plan is to incorporate them in the tests to automatically do that. Basically, as per above, a test could tag a sub-set with "exercise x, y and z should have output a, b, c"

@SleeplessByte
Copy link
Member Author

SleeplessByte commented May 30, 2019

@depsir I see you've removed your comment. If you don't mind I'd still like to respond to it because it might help other wondering the same thing:

[...] any reason why not using ts-jest? [...]

ts-jest was only a necessity when ts-node was still a real solution. It provided direct integration with compilation of typescript when running jest (and indeed also provide --watch support).

Since babel 7 and TypeScript 3+, Microsoft has been working to help people integrate their TypeScript tooling with their JavaScript tooling, among other things enabling you to "compile" typescript via Babel (7+), essentially by stripping away the type information nodes. This allows us to rely on babel for transpilation ánd typescript for type tooling instead of:

Source TypeScript > compilation (tsc/ts-node) > JavaScript > transpilation (babel) >  Output

Facebook no longer recommends ts-jest and I wouldn't be surprised if it will be deprecated in the (near) future (even though the author says it will prevail)

SleeplessByte added a commit that referenced this issue Jun 7, 2019
SleeplessByte added a commit that referenced this issue Jun 8, 2019
SleeplessByte added a commit that referenced this issue Jun 8, 2019
* Add smoke and snapshot test for two-fer

Work towards #9

* Add helpers for smoke and snapshot tests

* Add docs for smoke and snapshot tests
@SleeplessByte
Copy link
Member Author

There is now a document on 🌫 smoke tests and 📸 snapshot tests.

@SleeplessByte
Copy link
Member Author

Fixed by #75

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

No branches or pull requests

2 participants