Skip to content

Commit

Permalink
feat: Add jest as an ESLint environment and switch tests from tape …
Browse files Browse the repository at this point in the history
…to jest (#11)
  • Loading branch information
ntwb authored and jeddy3 committed Nov 21, 2016
1 parent e6f5c5f commit dac7ff0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
15 changes: 6 additions & 9 deletions __tests__/index.js
@@ -1,23 +1,20 @@
var config = require("../")
var test = require("tape")

test("test basic properties of config", function (t) {
t.ok(isObject(config.parserOptions), "features is object")
t.ok(isObject(config.env), "env is object")
t.ok(isObject(config.rules), "rules is object")
t.end()
it("test basic properties of config", function () {
expect(isObject(config.parserOptions)).toBeTruthy()
expect(isObject(config.env)).toBeTruthy()
expect(isObject(config.rules)).toBeTruthy()
})

test("load config in eslint to validate all rule syntax is correct", function (t) {
it("load config in ESLint to validate all rule syntax is correct", function () {
var CLIEngine = require("eslint").CLIEngine

var cli = new CLIEngine({
useEslintrc: false,
configFile: "eslintrc.json",
})

t.ok(cli.executeOnText("var foo\n"), "can executeOnText")
t.end()
expect(cli.executeOnText("var foo\n")).toBeTruthy()
})

function isObject(obj) {
Expand Down
3 changes: 2 additions & 1 deletion eslintrc.json
Expand Up @@ -5,6 +5,7 @@
},
"env": {
"es6": true,
"jest": true,
"node": true
},
"rules": {
Expand Down Expand Up @@ -42,6 +43,6 @@
"space-in-parens": [ 2, "never" ],
"space-infix-ops": 2,
"space-unary-ops": 2,
"spaced-comment": [ 2, "always" ]
"spaced-comment": [ 2, "always" ]
}
}
11 changes: 6 additions & 5 deletions package.json
Expand Up @@ -24,13 +24,14 @@
},
"devDependencies": {
"eslint": "^3.0.0",
"npmpub": "^3.0.3",
"tape": "^4.4.0"
"jest": "^17.0.3",
"npmpub": "^3.0.3"
},
"scripts": {
"jest": "jest",
"lint": "eslint -c eslintrc.json .",
"tape": "tape \"__tests__/**/*.js\"",
"test": "npm run lint && npm run tape",
"release": "npmpub"
"release": "npmpub",
"test": "npm run lint && npm run jest",
"watch": "jest --watch"
}
}

0 comments on commit dac7ff0

Please sign in to comment.