Sep 17, 2011 at 11:25 PM

Just some unstructured thoughts:

Port of AutoFixture in JavaScript.

  • Does it make any sense?
  • Is it doable? (language limitations, etc)
  • How the two versions would be kept in sync?
  • Probably a lite version?
Sep 19, 2011 at 7:57 AM

Very interesting idea :)

I know very little about JavaScript (yet), but given the current surge of interest in the language (including unit testing of JavaScript code) I assume that a general-purpose Test Data Builder is still appropriate.

Whether or not it's doable I don't know, but a quick web search indicates that JavaScript supports Reflection, which I'd presume would otherwise be the biggest stumbling block. Given the dynamic nature of the language I'd be inclined to think that it might even be easier to implement than in a statically typed language.

I don't think there are any easy way to keep the .NET version in sync with a potential JavaScript version, and it might not even be desirable. Various languages and platforms have their own idioms and patterns, and I find it best to utilize what the language has to offer - otherwise we'd end up with the lowest common denominator.

If we were to do this it'd make most sense to base it on the upcoming v3.0 architecture, as it has a more streamlined (and thus simpler) configuration API. I'd also start by focusing on the convention-based aspects and postpone support for Build<T>, Customize<T> and related method, since my experience has shown me that these are actually rarely needed.

Sep 19, 2011 at 8:33 PM

Alright :) Then we could create a plan sometime, to be better organized (and specific), about how this could be possible (starting with very-very small steps and eventually growing up).

For example:

  • Where should we host the project source code? (for ex. GitHub or perhaps CodePlex because AutoFixture is hosted there.)
  • What tools are needed for unit testing? (for ex. Jasmine, which does not require a DOM.)
  • What tools are needed for production code? (for ex. Visual Studio 2010 or Visual Studio 11 which adds better support for JavaScript code

I also know very little about JavaScript at this time. However, assuming that the AutoFixture.js will be of the same quality as AutoFixture, it will be a very good chance to practice with the language and learn a lot (the "right" way).

Sep 20, 2011 at 7:56 AM

Most of the questions I still don't feel qualified to answer, but I must admit that I've recently built up a preference for Git and GitHub, so I'd prefer to host it there.

Given that AutoFixture.js ought to be a 'pure' library (or whatever that's called in the JavaScript world), any unit testing framework that doesn't require a DOM or a browser sounds like a good idea.

When it comes to tooling, I'd also prefer to keep it as idiomatic to the language and platform as possible. It should be just as easy to use it with Node.js as within a browser-based unit test. While I don't mind supporting Visual Studio, I think we should also consider other alternatives. Basically, a JavaScript file is just a text file, so it should be possible to use it with any text editor.

Sep 20, 2011 at 7:24 PM
Edited Sep 20, 2011 at 8:02 PM

While we could use any text editor, at least it should support some basic functionality for programming.

We should also check and enforce some kind of coding style. (Something similar to using FxCop and StyleCop in C#.)

As part of the build process we could include:

Edit: Also agree for being as idiomatic as possible.

Sep 25, 2011 at 9:45 AM

Another good question that I investigate is what JavaScript version one should use.

Apr 24, 2012 at 9:53 PM

I think that this library is a good example of method chaining in JavaScript (it was promoted on Twitter by Smashing Magazine).

A very popular set of principles for writing consistent, idiomatic JavaScript code can be found here.