All Projects → Igmat → baset

Igmat / baset

Licence: MIT license
Testing tool for baseline strategy

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to baset

Recheck Web
recheck for web apps – change comparison tool with local Golden Masters, Git-like ignore syntax and "Unbreakable Selenium" tests.
Stars: ✭ 224 (+761.54%)
Mutual labels:  testing-tools, baseline
jest-watch-suspend
Suspending jest watch mode
Stars: ✭ 13 (-50%)
Mutual labels:  testing-tools
network image mock
Mock response for Image.network to help Flutter widget tests pass.
Stars: ✭ 22 (-15.38%)
Mutual labels:  testing-tools
distest
A library used to do integration testing on discord bots
Stars: ✭ 29 (+11.54%)
Mutual labels:  testing-tools
ruby-dns-mock
DNS mock server written on 💎 Ruby. Mimic any DNS records for your test environment with fake DNS server.
Stars: ✭ 50 (+92.31%)
Mutual labels:  testing-tools
mocat
🐈 Mocat is a mocking toolbar that allows you to interactively develop and test network requests.
Stars: ✭ 27 (+3.85%)
Mutual labels:  testing-tools
scenarioo
Scenarioo Docu Viewer for Automated Documentation using UI/E2E-Tests
Stars: ✭ 62 (+138.46%)
Mutual labels:  testing-tools
trafficator
Traffic generator for local analytics testing
Stars: ✭ 27 (+3.85%)
Mutual labels:  testing-tools
tools
Tools used for Penetration testing / Red Teaming
Stars: ✭ 63 (+142.31%)
Mutual labels:  testing-tools
json-crate
📦 json-crate: a minimalistic promise-based json database
Stars: ✭ 29 (+11.54%)
Mutual labels:  testing-tools
DebugWindow
一个在真机上测试时方便查看输出日志的小工具。(A debug tool which helps you view the console logs on the device when you test you APP.)
Stars: ✭ 36 (+38.46%)
Mutual labels:  testing-tools
pymongo inmemory
A mongo mocking library with an ephemeral MongoDB running in memory.
Stars: ✭ 25 (-3.85%)
Mutual labels:  testing-tools
ts-mock-imports
Intuitive mocking library for Typescript class imports
Stars: ✭ 103 (+296.15%)
Mutual labels:  testing-tools
blackhole
Blackhole is an MTA written on top of asyncio, utilising async and await statements that dumps all mail it receives to /dev/null.
Stars: ✭ 61 (+134.62%)
Mutual labels:  testing-tools
testcontainers
Selenide + TestContainers (Docker) sample project
Stars: ✭ 28 (+7.69%)
Mutual labels:  testing-tools
mock-hls-server
Fake a live/event HLS stream from a VOD one. Useful for testing. Supports looping.
Stars: ✭ 61 (+134.62%)
Mutual labels:  testing-tools
react-router-testing-utils
A collection of utilities to test React Router with React Testing Library (Work in progress 🚧)
Stars: ✭ 34 (+30.77%)
Mutual labels:  testing-tools
diferencia
Tool to detect regressions between services
Stars: ✭ 51 (+96.15%)
Mutual labels:  testing-tools
eat
Json based scenario testing tool(which can have test for functional and non-functional)
Stars: ✭ 41 (+57.69%)
Mutual labels:  testing-tools
apitest
this is a tool for testing Laravel REST API
Stars: ✭ 11 (-57.69%)
Mutual labels:  testing-tools

Become a patron

Contributions welcome License

BCH compliance CodeFactor Known Vulnerabilities

npm badge

BaseT

Tool for testing using baseline strategy.

WARNING: it's early beta, so documentation may have mistakes, if you face any problems feel free to create issues.

Table of Contents

What is it?

This tool much like Jest or Mocha gives you an opportunity to test your application by creating unit-tests, it also supports end-to-end testing (actually WILL support).

But unlike other most known frameworks it uses another approach which could be named Baseline Strategy. Initially inspired by TypeScript tests (see them here) it looks like thing that's able to change way we're testing.

Motivation

Current situation with TDD and tooling around it is complicated. There are a lot of problems and corner cases. And while everybody agrees that unit-testing is generally correct approach, amount of efforts required by it frequently makes TDD unsuitable for particular project.

We are trying to change it.

Our goal is moving TDD from processes (like agile, scrum, waterfall, etc.) to developer's tooling (like linters, compilers, etc.). In order to achieve it we have to focus on real strengths of TDD and unit-testing:

  1. Preventing unintentional breaking changes, in other words freezing existing behavior as some sort of 'baseline';
  2. Using documentation samples as tests and using tests as documentation.

To understand core idea and approach better, you can read Is TDD wrong? (RU)

How it works?

Let's assume you have module yourModule.js that exports one function. Baseline test (e.g. yourModule.spec.js) will look like this:

const yourModule = require('yourModule');

const oneUsage = yourModule('arguments', 'of', 'your', 'function');
const severalUsages = ['array', 'of', 'arguments'].map(yourModule);
let resultOfComplexUsageScenario;
// some code/function/promise that fulfils
// `resultOfComplexUsageScenario` with (a)sync value(s)

// actually any code that uses `yourModule` could be here

module.exports = {
    oneUsage,
    severalUsages,
    resultOfComplexUsageScenario,
    // any number of additional values
}

Run:

baset test

And this test will produce file yourModule.spec.tmp.base. It's temporary unverified baseline and contains all exported values (e.g. oneUsage, severalUsages, etc.). Just take a look at them and if you think they are correct run:

baset accept

And yourModule.spec.base will be generated. From this point you have test and baseline for yourModule that describe its behavior. All further test runs will compare generated yourModule.spec.tmp.base with yourModule.spec.base and fail if they are different, or pass otherwise.

Why I have to use it?

You haven't, but if you:

  • love TDD
  • hate TDD
  • don't care about it, but want to cover your application with tests
  • want to test everything
  • want to test only improtant cases
  • tired from describe, it, equalsTo that blows your tests and forces you to write a lot of code to test helloWorld.js
  • heard that tests are nearly the best type of documentation
  • never heard previous statement
  • disagree with it, because specs are unreadable in majority of cases
  • want it to be true for your project
  • feel lack of real usage examples in your project even though it has 100% coverage
  • feel lack of automated testing even though your documentation is full of examples

It worth trying baset.

Installation

For global, just run:

npm install -g baset

But we're recomending:

npm install --save-dev baset

and adding next lines to scripts section in your package.json:

"test": "baset",
"accept": "baset accept"

Usage

From command line:

baset <command> [options]

Commands:

Name Description Aliases
test Default. Creating temp baseline and comparing it to existing one t
accept Accepting new baseline a
scaffold Scaffolding specs for existing code s

Options:

Option Description Type Default value
‑‑version Show version number boolean
‑‑specs, ‑s Glob pattern for spec files string "**/*.spec.js"
‑‑bases, ‑b Glob pattern for baseline files string "**/*.base"
‑‑help, ‑h Show help boolean
‑‑reporter, ‑r TAP reporter for test results. false to get plain TAP output string "tap-diff"
‑‑plugins, ‑p Plugins used for your tests string | configuration ".spec.js$:baset-baseliner-json"
‑‑options, ‑o Options for plugins TBD {}
‑‑files, ‑f Glob pattern for project files. Used by scaffolder. string undefined
‑‑isolateContext Run each test in isolated context. May be usefull, if your tests/code may affect other tests by mutating globals. ATTENTION: this will slow down your tests. boolean false

isolateContext In your package.json:

{
    "scripts": {
        "test": "baset",
        "accept": "baset accept"
    },
    "baset": {
        "specs": "**/*.spec.js",
        "bases": "**/*.base",
        "plugins": {
            ".spec.js$": ["baset-plugin-module-name", "baset-baseliner-json"]
        },
        "options": {
            "baset-plugin-module-name": {
                // List of options for baset plugin.
                // All available should be listed at
                // plugins README.md file.
            }
        }
    }
}

In .basetrc or .basetrc.json:

{
    "specs": "**/*.spec.js",
    "bases": "**/*.base",
    "plugins": {
        ".spec.js$": ["baset-plugin-module-name", "baset-baseliner-json"]
    },
    "options": {
        "baset-plugin-module-name": {
            // List of options for baset plugin.
            // All available should be listed at
            // plugins README.md file.
        }
    }
}

Plugins configuration

The most important configuration option is plugins. You may configure it via command line or via configuration file or even using baset section in package.json.

Using configuration file (same for package.json)

{
    "plugins": {
        "${pattern}": "${options}"
    }
}

${pattern} - is regular expression for filename of your test files, so you may define different plugin options for different file types (e.g. using baset-reader-ts for .ts files and baset-reader-babel for .js files). ${options} - is string or string[] or object with following fields:

Field Description Type Default value
baseliner name or path to module, that is responsible for generating baseline string Required baset-baseliner-json
environment name or path to module, that mimics desired environment (e.g. browser) string undefined
readers name or path to module(s), that reads and transpiles specs and source code (e.g. babel, typescript) string[] | string undefined
resolvers name or path to module(s), that is able to resolve specific values (e.g. react components or pixi sprites) string[] | string undefined
imports name or path to module(s), that should be imported in test context (e.g. polyfills or reflect-metadata) string[] | string undefined
isolateContext Run each test in isolated context. May be usefull, if your tests/code may affect other tests by mutating globals. ATTENTION: this will slow down your tests. boolean false

If ${options} is string, then it used as baseliner name or path. If ${options} is string[], then it has to follow next agreement for its content:

["-env-pluginOrPath", ..."importPaths", ..."-reader-pluginsOrPaths",  ..."-resolver-pluginsOrPaths", "-baseliner-pluginOrPath"]

Where everything except baseliner is optional and ... means that several entities are allowed.

NOTE: grouping of entities is based on their names, so all plugins MUST contain substring -(env|reader|resolver|baseliner)-, except imports (last ones don't have any naming requirements).

Using CLI

Just type following command in your favorite terminal:

baset -p ${pattern}:${options}

${pattern} - is regular expression for filename of your test files (same as in previous paragraph). ${options} - is string[], where values are separated by : sign. This array has exactly same semantic as using string[] in configuration file.

Examples

Our tests folder contains projects used for end-to-end tests of baset package (using baset itself, of course), so you can use them as references for integrating baset into your workflow.

Plugins

There are only few plugins right now:

  1. baset-baseliner-json - default plugin that used for creating baseline from exported values of spec
  2. baset-baseliner-md - plugin that used for creating baselines in Markdown format
  3. baset-env-browser - simple plugin that enables browser API in specs and sources using jsdom package.
  4. baset-reader-ts - simple plugin that allows to write specs using TypeScript
  5. baset-reader-babel - simple plugin that allows to write specs using Babel
  6. baset-reader-md - simple plugin that allows to write specs using MarkDown where only code blocks are executed, and # headings used for tests structuring.
  7. baset-resolver-react - simple plugin that resolves react components as html
  8. baset-resolver-pixi - simple plugin that resolver pixi DisplayObject as base64 encoded image

Roadmap

You may track progress for first stable release at this milestone

Changelog

Recent changes can be viewed on the CHANGELOG

How to Contribute

Read to contribute CONTRIBUTING or

Donate me

How to Make Pull Request

Read to contribute PULL REQUEST TEMPLATE

License

Copyright (c) Ihor Chulinda. This source code is licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].