Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hurrymaplelad/sinon-codemod
Codemod scripts that update Sinon APIs
https://github.com/hurrymaplelad/sinon-codemod
Last synced: 6 days ago
JSON representation
Codemod scripts that update Sinon APIs
- Host: GitHub
- URL: https://github.com/hurrymaplelad/sinon-codemod
- Owner: hurrymaplelad
- Created: 2016-12-05T03:17:09.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-26T06:41:35.000Z (almost 6 years ago)
- Last Synced: 2024-08-02T07:14:25.774Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 28
- Watchers: 2
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-codemods - sinon-codemod - Codemod scripts that update Sinon APIs . (JavaScript)
README
## sinon-codemod
[![Build Status](https://img.shields.io/travis/hurrymaplelad/sinon-codemod.svg?style=flat-square)](https://travis-ci.org/hurrymaplelad/sinon-codemod) [![Code Style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
This repository contains a collection of codemod scripts based for use with
[JSCodeshift](https://github.com/facebook/jscodeshift) that help update Sinon APIs.### Setup & Run
* `npm install -g jscodeshift`
* `git clone https://github.com/hurrymaplelad/sinon-codemod.git` or download a zip file
from `https://github.com/hurrymaplelad/sinon-codemod/archive/master.zip`
* Run `npm install` in the sinon-codemod directory
* Alternatively, run [`yarn`](https://yarnpkg.com/) to install in the
sinon-codemod directory for a reliable dependency resolution
* `jscodeshift -t `
* Use the `-d` option for a dry-run and use `-p` to print the output
for comparison### Included Scripts
#### `extract-calls-fake`
Converts 3-argument calls to `sinon.stub(x,y,z)` into `sinon.stub(x,y).callsFake(z)`.
```sh
jscodeshift -t sinon-codemod/extract-calls-fake.js
```#### `migrate-to-v5`
Removes `sandbox` variable declaration
Removes `sinon.sandbox.create();`
Replaces `sandbox.restore()` with `sinon.restore()`
Replaces `sandbox.stub()` with `sinon.stub()`
Replaces `sandbox.spy()` with `sinon.spy()`
Replaces `sandbox.mock()` with `sinon.mock()`
```sh
jscodeshift -t sinon-codemod/migrate-to-v5.js
```