Permalink
Browse files

System tests

  • Loading branch information...
1 parent 0ba9459 commit d4e461552324b37067b6e8582914bbafbf4f23a1 @davidtheclark davidtheclark committed Oct 30, 2016
View
@@ -0,0 +1,18 @@
+{
+ "extends": [
+ "stylelint",
+ "plugin:flowtype/recommended"
+ ],
+ "parser": "babel-eslint",
+ "plugins": [
+ "flowtype"
+ ],
+ "rules": {
+ "arrow-spacing": 2,
+ "no-var": 2,
+ "object-shorthand": 2,
+ "prefer-const": 2,
+ "sort-imports": 2,
+ "template-curly-spacing": 2
+ }
+}
View
@@ -6,6 +6,7 @@
[libs]
./decls/lodash.js
+./decls/jest.js
./decls/stylelint.js
./decls/postcss.js
View
@@ -1,16 +1,20 @@
-sudo: false
language: node_js
-node_js:
- - '7'
- - '6'
- - '4'
+sudo: false
cache:
directories:
- node_modules
-before_install:
-- npm prune
-- npm update
-after_success: npm run coveralls
notifications:
webhooks:
- https://webhooks.gitter.im/e/d763493612da45967361
+matrix:
+ include:
+ - node_js: '6'
+ script: npm run lint && npm run flow
+ - node_js: '6'
+ script: npm run test-system
+ - node_js: '7'
+ script: npm run test
+ - node_js: '6'
+ script: npm run test
+ - node_js: '4'
+ script: npm run test
View
@@ -0,0 +1,128 @@
+// https://raw.githubusercontent.com/flowtype/flow-typed/master/definitions/npm/jest_v16.x.x/flow_v0.33.x-/jest_v16.x.x.js
+type JestMockFn = {
+ (...args: Array<any>): any;
+ mock: {
+ calls: Array<Array<any>>;
+ instances: mixed;
+ };
+ mockClear(): Function;
+ mockImplementation(fn: Function): JestMockFn;
+ mockImplementationOnce(fn: Function): JestMockFn;
+ mockReturnThis(): void;
+ mockReturnValue(value: any): JestMockFn;
+ mockReturnValueOnce(value: any): JestMockFn;
+}
+
+type JestAsymmetricEqualityType = {
+ asymmetricMatch(value: mixed): boolean;
+}
+
+type JestCallsType = {
+ allArgs(): mixed;
+ all(): mixed;
+ any(): boolean;
+ count(): number;
+ first(): mixed;
+ mostRecent(): mixed;
+ reset(): void;
+}
+
+type JestClockType = {
+ install(): void;
+ mockDate(date: Date): void;
+ tick(): void;
+ uninstall(): void;
+}
+
+type JestExpectType = {
+ not: JestExpectType;
+ lastCalledWith(...args: Array<any>): void;
+ toBe(value: any): void;
+ toBeCalled(): void;
+ toBeCalledWith(...args: Array<any>): void;
+ toBeCloseTo(num: number, delta: any): void;
+ toBeDefined(): void;
+ toBeFalsy(): void;
+ toBeGreaterThan(number: number): void;
+ toBeGreaterThanOrEqual(number: number): void;
+ toBeLessThan(number: number): void;
+ toBeLessThanOrEqual(number: number): void;
+ toBeInstanceOf(cls: Class<*>): void;
+ toBeNull(): void;
+ toBeTruthy(): void;
+ toBeUndefined(): void;
+ toContain(item: any): void;
+ toContainEqual(item: any): void;
+ toEqual(value: any): void;
+ toHaveBeenCalled(): void;
+ toHaveBeenCalledTimes(number: number): void;
+ toHaveBeenCalledWith(...args: Array<any>): void;
+ toMatch(regexp: RegExp): void;
+ toMatchSnapshot(): void;
+ toThrow(message?: string | Error): void;
+ toThrowError(message?: string): void;
+ toThrowErrorMatchingSnapshot(): void;
+}
+
+type JestSpyType = {
+ calls: JestCallsType;
+}
+
+declare function afterEach(fn: Function): void;
+declare function beforeEach(fn: Function): void;
+declare function afterAll(fn: Function): void;
+declare function beforeAll(fn: Function): void;
+declare function describe(name: string, fn: Function): void;
+declare var it: {
+ (name: string, fn: Function): ?Promise<void>;
+ only(name: string, fn: Function): ?Promise<void>;
+ skip(name: string, fn: Function): ?Promise<void>;
+};
+declare function fit(name: string, fn: Function): ?Promise<void>;
+declare var test: typeof it;
+declare var xdescribe: typeof describe;
+declare var fdescribe: typeof describe;
+declare var xit: typeof it;
+declare var xtest: typeof it;
+
+declare function expect(value: any): JestExpectType;
+
+// TODO handle return type
+// http://jasmine.github.io/2.4/introduction.html#section-Spies
+declare function spyOn(value: mixed, method: string): Object;
+
+declare var jest: {
+ autoMockOff(): void;
+ autoMockOn(): void;
+ clearAllMocks(): void;
+ clearAllTimers(): void;
+ currentTestPath(): void;
+ disableAutomock(): void;
+ doMock(moduleName: string, moduleFactory?: any): void;
+ dontMock(moduleName: string): void;
+ enableAutomock(): void;
+ fn(implementation?: Function): JestMockFn;
+ isMockFunction(fn: Function): boolean;
+ genMockFromModule(moduleName: string): any;
+ mock(moduleName: string, moduleFactory?: any): void;
+ resetModules(): void;
+ runAllTicks(): void;
+ runAllTimers(): void;
+ runTimersToTime(msToRun: number): void;
+ runOnlyPendingTimers(): void;
+ setMock(moduleName: string, moduleExports: any): void;
+ unmock(moduleName: string): void;
+ useFakeTimers(): void;
+ useRealTimers(): void;
+}
+
+declare var jasmine: {
+ DEFAULT_TIMEOUT_INTERVAL: number;
+ any(value: mixed): JestAsymmetricEqualityType;
+ anything(): void;
+ arrayContaining(value: mixed[]): void;
+ clock(): JestClockType;
+ createSpy(name: string): JestSpyType;
+ objectContaining(value: Object): void;
+ stringMatching(value: string): void;
+}
View
@@ -70,6 +70,7 @@
"devDependencies": {
"babel-cli": "^6.1.18",
"babel-eslint": "^7.0.0",
+ "babel-jest": "^16.0.0",
"babel-plugin-transform-flow-strip-types": "^6.14.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-es2017": "^6.14.0",
@@ -81,6 +82,7 @@
"eslint-config-stylelint": "^5.0.0",
"eslint-plugin-flowtype": "^2.21.0",
"flow-bin": "^0.35.0",
+ "jest": "^16.0.2",
"npm-run-all": "^3.0.0",
"npmpub": "^3.0.1",
"nyc": "^8.1.0",
@@ -91,16 +93,18 @@
"request": "^2.69.0",
"rimraf": "^2.5.2",
"sinon": "^1.16.1",
+ "strip-ansi": "^3.0.1",
"tape": "^4.2.0"
},
"scripts": {
+ "jest": "jest",
+ "test-system": "npm run jest",
"benchmark-rule": "babel-node scripts/benchmark-rule.js",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"lint:js": "eslint .",
"lint:md": "remark . --quiet --frail",
"lint": "npm-run-all --parallel lint:*",
"flow": "flow",
- "pretest": "npm run lint",
"tape": "babel-tape-runner \"src/**/__tests__/**/*.js\"",
"test": "nyc npm run tape",
"prebuild": "rimraf dist",
@@ -117,23 +121,11 @@
"transform-flow-strip-types"
]
},
- "eslintConfig": {
- "extends": [
- "stylelint",
- "plugin:flowtype/recommended"
+ "jest": {
+ "testPathDirs": [
+ "system-tests"
],
- "parser": "babel-eslint",
- "plugins": [
- "flowtype"
- ],
- "rules": {
- "arrow-spacing": 2,
- "no-var": 2,
- "object-shorthand": 2,
- "prefer-const": 2,
- "sort-imports": 2,
- "template-curly-spacing": 2
- }
+ "testRegex": ".*\\.test\\.js$"
},
"greenkeeper": {
"label": "PR: review needed"
@@ -56,7 +56,6 @@ export default function (expectation) {
})
},
})
- break
}
})
}
@@ -0,0 +1,6 @@
+{
+ "extends": "../.eslintrc",
+ "env": {
+ "jest": true
+ }
+}
@@ -0,0 +1,12 @@
+/* @flow */
+import * as systemTestUtils from "../systemTestUtils"
+import stylelint from "../../src"
+
+it("001", () => {
+ return stylelint.lint({
+ files: [systemTestUtils.caseStylesheetGlob("001")],
+ configFile: systemTestUtils.caseConfig("001"),
+ }).then(({ results }) => {
+ expect(systemTestUtils.prepResults(results)).toMatchSnapshot()
+ })
+})
Oops, something went wrong.

0 comments on commit d4e4615

Please sign in to comment.