tests: add schema tests · webpack/webpack-cli@70bf934

File tree

8 files changed

lines changed

  • test/binCases/errors/v5-schema-validation

8 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,3 @@

1+

module.exports = {

2+

entry: "hey"

3+

};

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,17 @@

1+

"use strict";

2+
3+

const validation = require("../../../../bin/utils/validate-options");

4+

const { run } = require("../../../testUtils");

5+
6+

test("validation", () => {

7+

const mockExit = jest.spyOn(process, "exit").mockImplementation(() => {});

8+

validation(null);

9+

expect(mockExit).toHaveBeenCalledWith(-1);

10+

mockExit.mockRestore();

11+

});

12+
13+

test("validation-success", () => {

14+

const { stdout, code } = run(__dirname, ["--config", "./options.js"]);

15+

expect(stdout).toContain("Can't resolve 'hey'");

16+

expect(code).toBe(2);

17+

});