All Projects → supabase → Doctest Js

supabase / Doctest Js

Licence: mit
Run JSDoc style doc examples as tests within your test suite

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Doctest Js

Redux Query
A library for managing network state in Redux
Stars: ✭ 1,055 (+1928.85%)
Mutual labels:  hacktoberfest
Beginner Level Android Studio Apps
A repository for Hacktoberfest conducted by Digital Ocean. Star the repository if you find it interesting.
Stars: ✭ 51 (-1.92%)
Mutual labels:  hacktoberfest
Awesome Android Kotlin Apps
👓 A curated list of awesome android kotlin apps by open-source contributors.
Stars: ✭ 1,058 (+1934.62%)
Mutual labels:  hacktoberfest
Siler
⚡ Flat-files and plain-old PHP functions rockin'on as a set of general purpose high-level abstractions.
Stars: ✭ 1,056 (+1930.77%)
Mutual labels:  hacktoberfest
Lingua Franca
Mycroft's multilingual text parsing and formatting library
Stars: ✭ 51 (-1.92%)
Mutual labels:  hacktoberfest
Golang Combinations
Golang library which provide an algorithm to generate all combinations out of a given string array.
Stars: ✭ 51 (-1.92%)
Mutual labels:  hacktoberfest
Perl5
🐫The Perl language interpreter.
Stars: ✭ 1,055 (+1928.85%)
Mutual labels:  hacktoberfest
Puppet Selinux
Puppet Module to manage SELinux on RHEL machines
Stars: ✭ 51 (-1.92%)
Mutual labels:  hacktoberfest
R6 Operator Counters
A website with a graph visualisation of how operators counter each other in Rainbow Six Siege.
Stars: ✭ 51 (-1.92%)
Mutual labels:  hacktoberfest
Gau
Fetch known URLs from AlienVault's Open Threat Exchange, the Wayback Machine, and Common Crawl.
Stars: ✭ 1,060 (+1938.46%)
Mutual labels:  hacktoberfest
Cliwrap
Library for running command line processes
Stars: ✭ 1,057 (+1932.69%)
Mutual labels:  hacktoberfest
Flutter Guide
📚 Flutter Guide on becoming a Master Flutterista
Stars: ✭ 51 (-1.92%)
Mutual labels:  hacktoberfest
Js Api Client
Typeform API js client
Stars: ✭ 51 (-1.92%)
Mutual labels:  hacktoberfest
Cloudsplaining
Cloudsplaining is an AWS IAM Security Assessment tool that identifies violations of least privilege and generates a risk-prioritized report.
Stars: ✭ 1,057 (+1932.69%)
Mutual labels:  hacktoberfest
React Tracking
🎯 Declarative tracking for React apps.
Stars: ✭ 1,062 (+1942.31%)
Mutual labels:  hacktoberfest
Synfig
This is the Official source code repository of the Synfig project
Stars: ✭ 1,056 (+1930.77%)
Mutual labels:  hacktoberfest
Ts Postgres
Non-blocking PostgreSQL client for Node.js written in TypeScript.
Stars: ✭ 51 (-1.92%)
Mutual labels:  hacktoberfest
Cm
Emacs' compilation-mode-like TUI application
Stars: ✭ 52 (+0%)
Mutual labels:  hacktoberfest
Lvm
Development repository for lvm Chef cookbook
Stars: ✭ 51 (-1.92%)
Mutual labels:  hacktoberfest
Emotecollector
Collects emotes from other servers for use by people who don't have Nitro
Stars: ✭ 51 (-1.92%)
Mutual labels:  hacktoberfest

doctest-js

Let your documentation be your testing suite.

Write JSDoc style doc examples on all your functions and then test them using doctest-js.

Contents

Getting Started

1. Install

npm install @supabase/doctest-js

2. Write @example comments

Create a JSDoc style @example on any functions that you want tested.

/**
 * Returns the sum of 2 numbers
 *
 * @example sum(1, 2)
 * //=> 3
 */
export const sum = (a, b) => {
  return a + b
}

Note that the expected return value must be prefixed by //=>.

3. Run the tests

Import the doctest function in your test suite and point it at the file.

import doctest from '@supabase/doctest-js';

describe('Doctests', () => {
  // file paths are relative to root of directory
  doctest('src/sum.js')
  doctest('src/someOtherFile.js')
})

Advanced

Multiple tests

You can run multiple tests for the same function.

/**
 * @example sum(1, 2)
 * //=> 3
 * @example sum(3, 4)
 * //=> 7
 */
export const sum = (a, b) => {
  return a + b
}

Testing classes

Testing classes requires you to pass a newed up instance of the class into the test itself. Here is a simple example:

// Arithmetic.js - a basic class which we need to test

class Arithmetic {
  constructor() {}

  /**
   * @example add(1, 2)
   * //=> 3
   */
  add(a, b) {
    return a + b
  }
}

export { Arithmetic }
// Arithmetic.test.js

const { Arithmetic } = require('./Arithmetic.js')

describe('passing doctest', () => {
  doctest('./Arithmetic.js', { instance: new Arithmetic() })
})

Usage online

See this in the wild:

Contributing

  • Fork the repo on GitHub
  • Clone the project to your own machine
  • Commit changes to your own branch
  • Push your work back up to your fork
  • Submit a Pull request so that we can review your changes and merge

Credits

Status

Ready for production! Watch and star this repo to keep updated on releases.

Watch this repo

Sponsors

We are building the features of Firebase using enterprise-grade, open source products. We support existing communities wherever possible, and if the products don’t exist we build them and open source them ourselves. Thanks to these sponsors who are making the OSS ecosystem better for everyone.

Worklife VC New Sponsor

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].