testing: add runIfMain
See original GitHub issueOnce we support imports.meta.url
and have a way for testing if the current script is the main script, we want to have a two line snippit of code that will allow any test to be executed as a standalone test deno foo_test.ts
rather than running the main entry point.
Essentially something like this:
https://github.com/tensorflow/tensorflow/blob/c4e61ac1fd0b3b48461e2876b20fe56c09faa2ff/tensorflow/python/lib/io/tf_record_test.py#L484
The most basic form would be something like this:
if (args[1] == imports.meta.url) {
testMain();
}
But perhaps we can make this shorter by having a function like runIfMain(imports.meta.url)
This came up in: https://github.com/denoland/deno_std/pull/129
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Avoid if __name__ == '__main__' in Python ... - Stack Overflow
My question is, can I avoid having to add this code to all files with the subclasses since the only thing that changes...
Read more >Unit Testing for your applications - PureBasic Forums - English
I had a requirement to include unit testing in a project I'm ... way to only run if the file is the main...
Read more >denolife/Lobby - Gitter
But I was getting prompts for my own static imports, I think. So is the test runner analyzing the test script and dynamically...
Read more >Adding Test Runs in Test Execution - Tricentis
Adding Test Runs in Test Execution. A Test Run is an executable version of a certain Test Case. The idea is that a...
Read more >deno標準テストモジュールの使い方 - Qiita
denoの標準ライブラリであるdeno_stdにはtestingモジュールが含まれています ... runIfMain } from 'https://deno.land/std@v0.26.0/testing/mod.ts'; ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@bartlomieju Yes - I think if we implement
window.location
as described in https://github.com/denoland/deno/issues/1750 then we can doCC @ry