Coder Social home page Coder Social logo

dwyl / learn-tdd Goto Github PK

View Code? Open in Web Editor NEW
2.7K 207.0 345.0 7.6 MB

:white_check_mark: A brief introduction to Test Driven Development (TDD) in JavaScript (Complete Beginner's Step-by-Step Tutorial)

License: Mozilla Public License 2.0

HTML 25.48% JavaScript 74.52%

learn-tdd's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

learn-tdd's Issues

Outdated version of QUnit

According to the QUnit documentation the current way to run a test is like this:

QUnit.test('This sample test should always pass!', function(assert) {
        var result = 1 + 1;
        assert.equal(result, 2); // just so we know everything loaded ok
      });

As opposed to this:

 test('This sample test should always pass!', function(assert) {
        var result = 1 + 1;
        assert.equal(result, 2); // just so we know everything loaded ok
      });

Could we update the QUnit script from this (QUnit 1.18.0):

<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-1.18.0.css">

to this (QUnit 2.1.1):

<script src="https://code.jquery.com/qunit/qunit-2.1.1.js"></script>

The examples would also need to be changed.

Request: Standard JS

How about adding standard-js as a Bonus feature as well.
Following JS Standards from standardjs
and getting that StandarJs Following badge for consistency.

js-standard-style

❇️ ❇️ ❇️ ❇️ ❇️ ❇️ ❇️

Add CONTRIBUTING.md File to Repo

As a person who is new to the DWYL Org/Community 🆕
I need to know how to contribute to the project effectively 💭
so that I can start my journey towards Doing What I Love with my Life! ❤️ ✅ 😂

Markdown:

_**Please read** our_
[**contribution guide**](https://github.com/dwyl/contributing)
(_thank you_!)

Note: these are line-separated but in the actual rendered page it's all one line.
see: https://github.com/dwyl/contributing/blob/master/CONTRIBUTING.md

Typo on README.MD

Hi Guys! Awesome work with this tutorial.

I'd just like to report this little typo in the second test case, which occours on sections Try it Yourself and Blanket.js:
The line
test('getChange(486, 500) should equal [100, 10, 2, 2]', function(assert) {
Should be
test('getChange(486, 600) should equal [100, 10, 2, 2]', function(assert) {

I'm going to submit a PR.

Error: Unknown handler: directory

We are using Hapi.js as our static server using the directory handler:

server.route( { method: 'GET', path: '/{param*}', handler: { directory: { path: Path.normalize(__dirname + '/') } } });

but when we attempt to upgrade to hapi v9.x we get:

Error: Unknown handler: directory

hapi-stack-trace

full stack trace:

/Users/n/code/learn-tdd/node_modules/hapi/node_modules/hoek/lib/index.js:723
    throw new Error(msgs.join(' ') || 'Unknown error');
          ^
Error: Unknown handler: directory
    at Object.exports.assert (/Users/n/code/learn-tdd/node_modules/hapi/node_modules/hoek/lib/index.js:723:11)
    at Object.exports.defaults (/Users/n/code/learn-tdd/node_modules/hapi/lib/handler.js:105:14)
    at new module.exports.internals.Route (/Users/n/code/learn-tdd/node_modules/hapi/lib/route.js:48:35)
    at internals.Connection._addRoute (/Users/n/code/learn-tdd/node_modules/hapi/lib/connection.js:359:17)
    at internals.Connection._route (/Users/n/code/learn-tdd/node_modules/hapi/lib/connection.js:351:18)
    at internals.Plugin._apply (/Users/n/code/learn-tdd/node_modules/hapi/lib/plugin.js:497:14)
    at internals.Plugin.route (/Users/n/code/learn-tdd/node_modules/hapi/lib/plugin.js:470:10)
    at Object.<anonymous> (/Users/n/code/learn-tdd/static-server.js:3:8)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
13 Aug 19:11:49 - [nodemon] app crashed - waiting for file changes before starting...

Loads of assumptions...!

Need to explain the anatomy of a test.

  • test description?
  • assertion
  • assertion methods (e.g. equal, deepEqual - why do we need two? how are they different?)

Nodemon is not required

Nodemon is not required for running static-server as we don't have to reload server when HTML changes. Adding it introduces additional complexity into the guide. Perhaps we should drop it?

Everything will work just fine with running node static-server.js.
JSDoc and Istambul generate static HTML files, so refreshing browser is enough to see changes.

Istanbul command [README.md line 823] fails as Istanbul isn't installed globally

A few of us had trouble getting this to work this morning as we hadn't installed Istanbul globally. It might be worth changing the suggested command to ./node_modules/.bin/istanbul cover tests.js. This would make it similar to the live-server command in the previous section.

I can create a PR if you're happy with the change?

Broken Image

In the tutorial, in the coin section, there should be an image showing the coins used in the UK (labeled "GBP coins"), but it's a dead link. It points here, which you'll see returns "not found."

In the markdown, the image link is https://raw.githubusercontent.com/nelsonic/learn-mocha/master/images/gbp-coins.jpg. It appears that the repository at nelsonic/learn-mocha might have been moved to dwyl/learn-mocha, so the image link should be updated to https://github.com/dwyl/learn-mocha/blob/master/images/gbp-coins.jpg.

Typos & clarifications

Here are a few suggested corrections of typos and/or clarifications!

I fixed the typos as I went along so I have these in a file (stupidly I forgot to fork and just cloned - so used to working on organisation documents!! 😳 Happy to PR these in later today from a fork). I made the stuff below that I didn't change in that file bold so you can see what they are straight away.

Add daydream and nightmare to 'What to learn next'

I think dwyl's daydream and nightmare tutorial for automated testing would be very useful to add to the 'What to learn next' bullets.

Currently there is only a link to a Nightwatch tutorial for automated testing (alongside links for other testing types ie. test coverage/ node testing).

Do people think it's clearest to only suggest one automated testing resource rather than two? By this I mean Nightwatch vs Daydream and Nightmare (coupled together as a pair).

I think Daydream and Nightmare have the obvious advantage of being technically easy to implement which also helps to save time. Are there any specific benefits for suggesting Nightwatch (if so perhaps it would be good to add them to the description so readers can make an informed decision)?

QUnit "enable coverage" not automatically ticked.

In the live server section there needs to be a step letting you know that you need to tick the "Enable coverage" box as it is not ticked as default.

box-ticking

Seems like a little thing but it stumped us for a frustrating amount of time!

Add "What Next?" section?

At the end of the readme, should we add a "_What Next?_" section so people know what they should learn next.

undefined var C

The function under this headline "Keep Cheating or Solve the Problem?" references C.coins twice... I think the C should not be there...

Repo does not recognize istanbul after npm install qunitjs qunit-tap istanbul --save-dev

Hi,

When I typed npm install qunitjs qunit-tap istanbul --save-dev in the command line, and then typed istanbul cover test.js, I got zsh: command not found: istanbul. However, when I typed node test.js, everything was fine. I already had Node installed, but did not have istanbul installed. This was my first attempt to do so. Is there a step missing here in the instanbul installment process? Also, fyi, you failed to tell people to npm init to create their package.json file. Perhaps you should include that. Also, not everyone has Node.js installed. At least direct them to where they can learn how to install it if they don't already have it installed. Otherwise, thanks so much for this intro to TDD!

Adapting this as a new resource for FAC 11

Hi @nelsonic!

@finnhodgkin and I are mentoring Testing Week so we're currently going through all the workshops we did.

We're going to be switching from QUnit to Tape (as per this proposal), so we need to re-work lots of the existing material.

We love this workshop and think it's a great resource as it is, so we wouldn't really want to change it. The vending machine change challenge fits TDD really well, so we'd love to keep using the concept.

We're wondering if you'd be happy with us creating a new workshop inspired by this one, but trimmed down and using Tape instead?

TDD in Ruby

Hi any plans for TTD in Ruby for beginners as well? 😄

Readme.md in learn-tdd incorrect code under "Create the getChange function"

Hi @nelsonic, in the TDD tutorial when you are writing the First Requirement dummy test. you have some code under "your index.html should now look like this:” In here the test has a function without assert being the argument.

So if one was to copy the code and then run the html file in the browser, it would fail with ReferenceError: assert is not defined.

Different approach to getChange

 function getChange(totalPayable, cashPaid) {
        var change = [];
        var remaining = cashPaid - totalPayable;
        while (remaining > 0) {
            for (i = 0; i < coins.length; i++) {
                if (remaining >= coins[i]) {
                    change.push(coins[i]);
                    remaining = remaining - coins[i];
                    i = i - 1;
                }
            }
        }
        return change;
    };

Replace pit crew image with one that didn't cost their driver the championship

The photograph used to illustrate a 'consistent and beautifully illustrated team' shows the Ferrari F1 pit crew in 2008. Given that the pit crew cost Felipe Massa the championship that year by failing to remove the fuel hose from his car during a refuelling stop at the Singapore GP, it may be worth using an image of a different pit crew. Red Bull are a safe bet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.