Simple frontend TypeScript testing utility

Related tags

Testing TSFTest
Overview

TSFTest

Simple frontend TypeScript testing utility.

Installation

Install webpack in your project directory:

npm install --save-dev webpack webpack-cli typescript ts-loader

Install the typescript functions also in your project directory:

npm install --save-dev tsftest

Install chromedriver and add to path https://chromedriver.chromium.org/getting-started

Use pip to install the tsftest command (where path_to_dir is the folder containing setup.py):

pip install path_to_dir --user

Create a test folder in your project if you don't have one already.

Either:

  • Add tsconfig.json and webpack.config.js files to the test folder with settings to compile to test_dir/dist/test.js.

OR

  • See the setup command in the Usage section for a simple command to add these files with a default configuration.

Usage

To add default required configuration files if the files don't exist, run:

python -m tsftest setup path_to_test_folder

To run the tests use (consider setting this in your package.json->scripts.test):

python -m tsftest path_to_test_folder

You can make a browser window open with the tests allowing the use of browser developer tools with:

python -m tsftest --headed path_to_test_folder

Example Test

{ let request = new ApiRequest("GET", "/"); t.describe("ApiRequest should have GET method"); t.assert(request.method, "GET"); } ) test("Api class", async (t: Test) => { let api = new Api(new URL("http://127.0.0.1"), new ApiCredentials()) let request = new ApiRequest("GET", "/"); let response = await api.call(request) t.describe("Api.call should return an instance of Response"); t.assertInstance(response, Response); t.describe("Testing successful Api.call to /"); t.assert(response.ok, true); } ) ">
import { Api, ApiCredentials, ApiRequest } from "../src/api";
import { test, Test } from "tsftest"

test("ApiRequest class",
    (t: Test) => {
        let request = new ApiRequest("GET", "/");

        t.describe("ApiRequest should have GET method");
        t.assert(request.method, "GET");
    }
)

test("Api class",
    async (t: Test) => {
        let api = new Api(new URL("http://127.0.0.1"), new ApiCredentials())
        let request = new ApiRequest("GET", "/");

        let response = await api.call(request)

        t.describe("Api.call should return an instance of Response");
        t.assertInstance(response, Response);

        t.describe("Testing successful Api.call to /");
        t.assert(response.ok, true);
    }
)
You might also like...
Automatically mock your HTTP interactions to simplify and speed up testing

VCR.py 📼 This is a Python version of Ruby's VCR library. Source code https://github.com/kevin1024/vcrpy Documentation https://vcrpy.readthedocs.io/ R

fsociety Hacking Tools Pack – A Penetration Testing Framework
fsociety Hacking Tools Pack – A Penetration Testing Framework

Fsociety Hacking Tools Pack A Penetration Testing Framework, you will have every script that a hacker needs. Works with Python 2. For a Python 3 versi

Scalable user load testing tool written in Python
Scalable user load testing tool written in Python

Locust Locust is an easy to use, scriptable and scalable performance testing tool. You define the behaviour of your users in regular Python code, inst

Automatically mock your HTTP interactions to simplify and speed up testing

VCR.py 📼 This is a Python version of Ruby's VCR library. Source code https://github.com/kevin1024/vcrpy Documentation https://vcrpy.readthedocs.io/ R

Language-agnostic HTTP API Testing Tool
Language-agnostic HTTP API Testing Tool

Dredd — HTTP API Testing Framework Dredd is a language-agnostic command-line tool for validating API description document against backend implementati

Web testing library for Robot Framework

SeleniumLibrary Contents Introduction Keyword Documentation Installation Browser drivers Usage Extending SeleniumLibrary Community Versions History In

✅ Python web automation and testing. 🚀 Fast, easy, reliable. 💠
✅ Python web automation and testing. 🚀 Fast, easy, reliable. 💠

Build fast, reliable, end-to-end tests. SeleniumBase is a Python framework for web automation, end-to-end testing, and more. Tests are run with "pytes

One-stop solution for HTTP(S) testing.
One-stop solution for HTTP(S) testing.

HttpRunner HttpRunner is a simple & elegant, yet powerful HTTP(S) testing framework. Enjoy! ✨ 🚀 ✨ Design Philosophy Convention over configuration ROI

Declarative HTTP Testing for Python and anything else

Gabbi Release Notes Gabbi is a tool for running HTTP tests where requests and responses are represented in a declarative YAML-based form. The simplest

Owner
null
pytest plugin for distributed testing and loop-on-failures testing modes.

xdist: pytest distributed testing plugin The pytest-xdist plugin extends pytest with some unique test execution modes: test run parallelization: if yo

pytest-dev 1.1k Dec 30, 2022
PacketPy is an open-source solution for stress testing network devices using different testing methods

PacketPy About PacketPy is an open-source solution for stress testing network devices using different testing methods. Currently, there are only two c

null 4 Sep 22, 2022
Command line driven CI frontend and development task automation tool.

tox automation project Command line driven CI frontend and development task automation tool At its core tox provides a convenient way to run arbitrary

tox development team 3.1k Jan 4, 2023
A command-line tool and Python library and Pytest plugin for automated testing of RESTful APIs, with a simple, concise and flexible YAML-based syntax

1.0 Release See here for details about breaking changes with the upcoming 1.0 release: https://github.com/taverntesting/tavern/issues/495 Easier API t

null 909 Dec 15, 2022
Simple assertion library for unit testing in python with a fluent API

assertpy Simple assertions library for unit testing in Python with a nice fluent API. Supports both Python 2 and 3. Usage Just import the assert_that

null 19 Sep 10, 2022
Hypothesis is a powerful, flexible, and easy to use library for property-based testing.

Hypothesis Hypothesis is a family of testing libraries which let you write tests parametrized by a source of examples. A Hypothesis implementation the

Hypothesis 6.4k Jan 5, 2023
Generic automation framework for acceptance testing and RPA

Robot Framework Introduction Installation Example Usage Documentation Support and contact Contributing License Introduction Robot Framework is a gener

Robot Framework 7.7k Jan 7, 2023
Scalable user load testing tool written in Python

Locust Locust is an easy to use, scriptable and scalable performance testing tool. You define the behaviour of your users in regular Python code, inst

Locust.io 20.4k Jan 4, 2023
A modern API testing tool for web applications built with Open API and GraphQL specifications.

Schemathesis Schemathesis is a modern API testing tool for web applications built with Open API and GraphQL specifications. It reads the application s

Schemathesis.io 1.6k Jan 6, 2023
Sixpack is a language-agnostic a/b-testing framework

Sixpack Sixpack is a framework to enable A/B testing across multiple programming languages. It does this by exposing a simple API for client libraries

null 1.7k Dec 24, 2022