Coder Social home page Coder Social logo

javascript-jest's Introduction

TDDBC for JavaScript + Jest with Node.js

これは、TDDBCのNode.js + Jest 向けプロジェクトです。

Documentation

セットアップ&テスト

$ git clone https://github.com/tddbc/javascript-jest.git
$ cd javascript-jest
$ npm install
$ npm test

> [email protected] pretest /Users/dictav/golang/src/github.com/dictav/javascript-jest
> npm run fmt && npm run lint

> [email protected] fmt /Users/dictav/golang/src/github.com/dictav/javascript-jest
> prettier --write *js *.json lib/*js

jest_js.config.js 53ms
jest_mjs.config.js 7ms
main.js 8ms
main.mjs 7ms
prettier.config.js 4ms
package-lock.json 355ms
package.json 30ms
lib/sample.js 11ms
lib/sample.mjs 7ms
lib/sample_test.js 11ms
lib/sample_test.mjs 7ms

> [email protected] lint /Users/dictav/golang/src/github.com/dictav/javascript-jest
> eslint main.js main.mjs lib/*js

> [email protected] test /Users/dictav/golang/src/github.com/dictav/javascript-jest
> npm run test:js && npm run test:mjs

> [email protected] test:js /Users/dictav/golang/src/github.com/dictav/javascript-jest
> jest --config jest_js.config.js

 PASS  lib/sample_test.js
  ✓ exported class (2ms)
  ✓ private function (2ms)

Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        1.154s, estimated 2s
Ran all test suites.

コマンド

コマンド 内容
npm test lint とテストをまとめて行います
npm run test:js CommonJS の実装のテストを行います
npm run test:mjs ES Module の実装のテストを行います
npm run fmt コードの整形を行います
npm run lint コードの静的検証を行います
npm run watch:js ファイル変更を監視し、変更があったらテストを自動で行います
npm run watch:mjs ファイル変更を監視し、変更があったらテストを自動で行います

License

Copyright (c) 2019 TDD BaseCamp and other contributors

http://devtesting.jp/tddbc/

https://github.com/tddbc

Licensed under the MIT license.

javascript-jest's People

Contributors

azusa avatar dependabot[bot] avatar dictav avatar grimrose avatar kazweda avatar kuniwak avatar nnasaki avatar shishi avatar sue445 avatar twada avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

javascript-jest's Issues

npm run test:mjs を実行すると TypeError: _.r is not a function でテストがコケる

OS: macOS Big Sur 11.6

Node.js/npm: v12.22.6/v6.14.15
Node.js/npm: v14.18.0/v6.14.15
Node.js/npm: v16.10.0/v7.24.1

$ git clone https://github.com/tddbc/javascript-jest.git
$ cd javascript-jest.git
$ npm i

npm run test:jsは成功する

$ npm run test:js

> [email protected] test:js
> jest --config jest_js.config.js

 PASS  lib/sample_test.js
  ✓ exported class (1ms)
  ✓ private function (1ms)

Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        0.587s, estimated 1s
Ran all test suites.

npm run test:mjsは失敗する

$ npm run test:mjs

> [email protected] test:mjs
> jest --config jest_mjs.config.js

 FAIL  lib/sample_test.mjs
  ● Test suite failed to run

    TypeError: _.r is not a function

    > 1 | import { strict as assert } from "assert";
        |                          ^
      2 | import Sample from "./sample";
      3 | import rewire from "rewire";
      4 |

      at Object.<anonymous> (lib/sample_test.mjs:1:26)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.351s
Ran all test suites.

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.