Giter Site home page Giter Site logo

scala-e2e-js-testkit's Introduction

Testing Scala project End-to-End

This is a POC for testing Scala project End-to-End using JavaScript + Karma + Mocha specs syntax.

Purpose

See my presentation here: http://talks.indrasius.lt/js-e2e

Usage example

package lt.indrasius.products.it

import lt.indrasius.e2e.js.{KarmaRunner, MochaSpec}

/**
 * Created by mantas on 15.3.23.
 */
class ProductAPISpec extends MochaSpec("e2e/product-api-spec.js") with KarmaRunner {
  config("baseUrl" -> s"http://localhost:${EmbeddedEnvironment.SERVER_PORT}/api/products/")

  bowerInclude("promise-js", "underscore")
  classPathInclude("e2e/http-client.js")
}

See the bowerInclude and classPathInclude for including the static files into the Karma context.

The file should reside in src/test/resources/e2e/product-api-spec.js

describe("a product service", function() {
    var http = new HttpClient(jsExecConfig.baseUrl);

    it("store and retrieve product data", function() {
        var givenProductId = "XYZDEF";

        return givenProductExists(givenProductId, "Hello", "212 EUR")
            .then(function() {
                return http.get(givenProductId)
            })
            .then(function(gotResult) {
                expect(gotResult.name).to.be.equal("Hello");
                expect(gotResult.price).to.be.equal("212 EUR");
            });
    });

    it("get all the products", function() {
        return givenRandomProductsExist(3)
            .then(function(productsInStock) {
                return http.get("")
                    .then(function(gotResult) {
                        expect(gotResult).to.haveBodyThatContains(productsInStock)
                    });
            });
    });
});

Running from IDE

Simply Right click on the MochaSpec in Scala or use an appropiate shortcut.

Running from SBT

libraryDependencies += "lt.indrasius" %% "js-e2e-testkit" % "1.0-SNAPSHOT" % "test"

testFrameworks += TestFramework("lt.indrasius.e2e.js.sbt.Framework")

scala-e2e-js-testkit's People

Contributors

mantasindrasius avatar

Watchers

James Cloos avatar  avatar

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.