Skip to content

Make testing is intuitional and convenient in comment, markdown, and so on.

License

Notifications You must be signed in to change notification settings

imcuttle/intuitional-test

Repository files navigation

intuitional-test

Build status Test coverage lerna Prettier Conventional Commits

Make testing is intuitional and convenient in comment, markdown, jsdoc @example comment and so on.

Syntax

const add = (a, b) => a + b

// looseEqual
add(1, 1) // => 2

const a = {}
// strictEqual
a // ==> a

// not looseEqual
;[{}] // != {}

// not strictEqual
;[{ abc: 'abc' }]
/* !== [
   {abc: 'abc'}
 ] */

const addAsync = (a, b) => Promise.resolve(a + b)
// async resolve value
addAsync(1, 1) // => Promise<2>

How it works?

intuitional-test use babel-preset-intuitional-test transforming the above syntax as some assertions.

For example:

  • Input
const add = (a, b) => a + b
// looseEqual
add(1, 1) // => 2
  • Output
const add = (a, b) => a + b
assert.deepEqual(add(1, 1), 2, "looseEqual")

This is a case of transforming, It's different with intuitional-test-babel-jest.

  • Output
const add = (a, b) => a + b

describe('filename ...', () => {
  it("looseEqual", () => {
    expect(add(1, 1)).toEqual(2)
  })
})

So we could run intuitional test in jest by intuitional-test-babel-jest transformer or my-runner by preset.

Even writing intuitional test in markdown and jsdoc.

  • Markdown
```javascript namespace=test
1 + 2 // => 3
```
  • JSDoc
/**
 * @name add
 * @example
 * add(1, 2) // => 3
 */
const add = (a, b) => a + b

Contributing

  • Fork it!
  • Create your new branch:
    git checkout -b feature-new or git checkout -b fix-which-bug
  • Start your magic work now
  • Make sure npm test passes
  • Commit your changes:
    git commit -am 'feat: some description (close #123)' or git commit -am 'fix: some description (fix #123)'
  • Push to the branch: git push
  • Submit a pull request :)

Authors

This library is written and maintained by imcuttle, moyuyc95@gmail.com.

License

MIT - imcuttle 🐟

About

Make testing is intuitional and convenient in comment, markdown, and so on.

Resources

License

Stars

Watchers

Forks

Packages

No packages published