Hi,
May be you plan to do something like TDD framework for solely Typescript? It would be really great.
P.S. Please, do not point me to the Jasmin(qUnit) + Chutzpah for Visual Studio. This one is clumsy and buggy for a code written in TS. May be because of really Rapid Development in Typescript. Sorry, nothing personal.
I'm not an expert in TDD or JavaScript testing frameworks, but I recently read some compelling arguments for tape, mainly focused on its simplicity as compared to mocha. I haven't had time to play with it much but there are solid .d.ts files available.
Regarding your request, it would seem to be in conflict with one of the core goals of TypeScript: to leverage and support JavaScript by enabling tooling, supporting existing and emerging patterns, and mapping itself over JavaScript libraries and frameworks, but _not_ to provide a standard library of any kind. For example, TypeScript does not come bundled with a promise polyfill to support its async implementation. It is a language, and in my opinion an excellent one, but it is not a platform.
Yeah! Why would not TypeScript team also develop:
all in TypeScript for TypeScript! Huh?
As others have pointed out (or implied), it is inconsistent with the design goals of TypeScript.
Because TypeScript is _always_ transpiled code, it wouldn't make sense to run your tests _in TypeScript_ but rather transpile both your source and your tests and run them in an environment that you intent to support.
Intern 4 will be written TypeScript and coupled with something that maps back coverage to the original files, you can get an understanding of what you are actually testing and covering. For Dojo 2, we currently write all our source code and tests in TypeScript and do our coverage analysis against the source files.
But running tests in Jasmine + Chutzpah makes my code buggy.
And consequently, I cannot use it normally.
And, consequently, I am writing non-testable code.
I dislike to write it without TDD (code first). And I am a TDD-infected person :) .
That's a reason of this Epic Request.
Your reasons are understood, but it is not something the TypeScript team will deliver for you... Wanting something and getting something are two different things.
@alerya Are you saying that the frameworks you mention are giving you issues when you use them with TypeScript? Or do you just want to find a better testing framework.
If the latter, there are other test frameworks out there you may find more reliable/usable.
If the former, perhaps the .d.ts files are poorly written or maintained. As @kitsonk said, the JavaScript produced by the TypeScript compiler is ultimately what runs.
If you are having trouble finding a reliable/simple test framework, you could go back to basics, temporarily, to validate certain assumptions. E.g.
_testing/assert.ts_
export const areAqual = <T>(actual: T, expected: T) => actual === expected;
export const isTrue = (expression: boolean | (() => boolean)) =>
typeof expression === "function"
? expression()
: expression;
export const isFalse = (expression : boolean | (() => boolean)) => !isTrue(expression);
export default isTrue
Edit: I mention going back to basics because sometimes testing setups become overly configurable, have implicit global state shared within a test run, concurrency issues, and other problems. So if you are having trouble try running some tests by hand with a few helpers to validate that the SUT is behaving deterministically.
Good point, aluanhaddad. I am agreed. But what about Tooling in VS ?
For example a connector to Test Explorer?
And... you know, I wan't everybody invents its own wheel. Why not to do something special for Typescript, not for JS. May be I am little bad in my language I meant my purpose is Typescript and not Javascript (with its various undoubtable great ES3,4,5,6,7,8,9 and so on). Mainly, TS declared as OOP style of life, so we need all modern tools for this paradigm we have in other OOP languages.
If it is impossible, then we write untestable code in TS. It disappoints me and turns me back to JS horror kingdom.
Toolingwise, Visual Studio has an integrated task runner for gulp and grunt, which prints to a dedicated window. A while ago, I made a request/suggestion to @madskristensen to support exporting the output to VS error/warnings/messages window, I believe something like this may be in the works, but I'm not sure about Test Explorer. Integration could definitely be improved.
As to your point about OOP, this is also not a goal of TypeScript beyond supporting the OOP patterns that exist JavaScript.
I have to frankly say that I reject the notion that OOP is more testable. Also, there is a very strong trend across most mainstream languages (C++, C#, Java) to incorporate functional programming patterns. JavaScript has long had strong support for functional programming techniques, and TypeScript's type system expresses these very well.
Don't let classes in TypeScript, which are simply ES6 classes with a little extra sugar for initializing properties, give you the impression that they add Java style OOP to JavaScript. They are all just functions.
Sure I understand what is JS :)
Simply wanna have a set of standartized tools make us all to code the same way and tied to solely Typiscript.
It sounds like you want better tools. I'm definitely with you on that. I assume by "us all", you mean you and your team, and consistency within a team is critical. However, a mistake some of us make when learning TypeScript or ECMAScript 6+ is trying to forget about or not learning about ECMAScript 5 (by the way, TypeScript is a great way to learn that as well because of the tooling it provides).
Either way, the function I use most often when writing in any of these languages/dialects is probably Array.prototype.map as in
[0, 1, 2, 3].map(Math.sqrt);
I don't really know how to crystallize better my thougths. Simply I wanna a have handy tool for TDD infected people who can share their experience and may be write books about TDD in TS (and infect other, yeah). Right now we have a tool for JS, but in this case TS seems not necessary. And as you saw before people wanna have not only it (see aleksey-bykov's post).
I believe @aleksey-bykov was being sarcastic, but I am not sure.
The larger point is there is no such thing as TypeScript without JavaScript.
Testing is infinitely important, and TDD has a lot of merits, but these ideas are orthogonal to the language in which you are writing. The fact that they grew up within the Java Community is inconsequential. Rober C. Martin a father and outspoken advocate of TDD, has been suggesting that people use Clojure. Clojure is a dialect of lisp.
It's safe to assume aleksey is being sarcastic until proven otherwise :heart:
If you're able to do TDD in JS, you can do it in TS too. There are tons of JS TDD tools and frameworks that work excellently with TS, of course. If none of them are suitable for you, we're certainly not going to be able to deliver one that is.
Most helpful comment
Yeah! Why would not TypeScript team also develop:
all in TypeScript for TypeScript! Huh?