Foundations & Test First

 

Topics

 
  • Foundations Overview
  • Introduction to Learndot
  • Test First JavaScript
 

Foundations Overview

 
  • Required pre-work for Grace Hopper and Fullstack Academy Immersive Programs
  • Designed to increase your knowledge in core concepts
  • Weekly Assignments and Challenges with due dates
  • Support
    • ​​Discuss
    • Live Office Hours
    • Livestreams
    • Only email an Instructor for Personal Matters
  • ​Foundations Assessment
 

Learndot Tour

 
  • Learndot is our main learning platform
  • Integrations
  • Workshops
  • Calendar
  • Discuss
  • Add a Photo
 

Introduction to TestFirst

 
  • Test First is one of the most important assignments in Foundations.
  • How to get started?
    • Visit: https://github.com/FullstackAcademy/FullstackTestFirst
      • If you don't have access, email foundations@fullstackacademy.com
    • Fork the Repository.
    • Clone the Forked Repository (the Repository on your Github Account) to your local machine.
    • This keeps the Github repository private making your forked repository easier to review and grade!
 

Test Driven Learning

 
  • Test Driven learning is a lot like taking a test!
  • If we asked you the question:
    • Are you a Cat or Dog Person?
      • ​1. Interpret and read the question.
      • 2. Create a response.
      • 3. Submit the response.
    • What is "x" in the following equation:
      • ​5 + "x" = 9
      • 1. Interpret and read the question.
      • 2. Determine what "x" is based on the information provided in the question.
      • 3. Submit your value for "x" and see if 5 + 4 = 9
 

Let's read a Test Spec

 
describe("First Day of Foundations", function(){
  
  it('is a function object', function() {
    expect(typeof firstDay).toEqual('function');
  });

  it('returns the string "first day"', function() {
    expect(firstDay()).toEqual("first day");
  });

});

  

Let's Solve our Test Spec

 
// FILE: first_day_specs.js  NOTE - THIS LOADS AFTER
// the first_day.js file

describe("First Day of Foundations", function(){
  
  it('is a function object', function() {
    expect(typeof firstDay).toEqual('function');
  });

  it('returns the string "first day"', function() {
    expect(firstDay()).toEqual("first day");
  });

});

  
// FILE: first_day.js

function firstDay() {
  return "first day";
}

Jasmine

 
  • Jasmine was created by Pivotal Labs
  • It is the testing framework we'll use in Test First
  • Documentation: http://jasmine.github.io/2.0/introduction.html
  • Overall, it will provide us pre-defined functions that will help us test our code!
 

Jasmine Functions

 
describe("the title of the suite of test specs", function(){
  
    it('name of spec', function(){
        
    });

    it('name of spec', function(){
        
    });

    it('name of spec', function(){
        
    });

});
  • `describe` - encapsulates and names a set of test specs
  • `it` - an individual test spec
 

Jasmine Functions

 
describe("the title of the suite of test specs", function(){
  
    it("helloWorld return value", function(){
        expect(helloWorld()).toEqual("Hello World");
    });

    it("myName variable", function(){
        expect(myName).toEqual("Scott");
    });

});
  • `expect` - accepts a value to match.
    • chained to a matcher
    • `toEqual` is the matcher
    • expect(someValue).toEqual(true);
 

Jasmine Functions

 
describe("the title of the suite of test specs", function(){
    
    var total;
    
    beforeEach(function() {
         total = 2;
    })

    it("increase total by 1", function(){
        total += increaseTotal();
        expect(total).toEqual(3);
    });

    it("increase total by argument", function(){
        total += increaseTotal(5);
        expect(total).toEqual(8);
    });

});
  • `beforeEach` - a block of code that runs before every test spec ( `it` function).
    • is useful for resetting values to default values
 

Let's take a look at some real test specs!

 
Made with Slides.com