Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Aug 7, 2020
1 parent 408f5cd commit f078398
Show file tree
Hide file tree
Showing 14 changed files with 507 additions and 36 deletions.
29 changes: 9 additions & 20 deletions config/builds/vest.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,8 @@ const plugins = ({ name, format }) => {
return PLUGINS;
};

const pickExtension = format => {
if (format === FORMAT_ES) {
return 'mjs';
}

if (format === FORMAT_CJS) {
return 'cjs';
}

return 'js';
};

const addEsmDir = () => {
const fullPath = path.join(DIST_PATH, DIR_NAME_DIST, DIR_ESM);
const fullPath = path.join(DIST_PATH, DIR_ESM);

fs.ensureDirSync(fullPath);

Expand All @@ -97,11 +85,7 @@ const buildConfig = ({
} = {}) => ({
input: path.join(PACKAGE_PATH, 'src', input),
output: {
file: [
path.join(DIST_PATH, outputDir, PACKAGE_VEST),
name,
pickExtension(format),
]
file: [path.join(DIST_PATH, outputDir, PACKAGE_VEST), name, 'js']
.filter(Boolean)
.join('.'),
format: format || FORMAT_UMD,
Expand All @@ -118,8 +102,13 @@ addEsmDir();
export default [
buildConfig({ format: FORMAT_UMD }),
buildConfig({ name: NAME_ES5, format: FORMAT_UMD }),
buildConfig({ format: FORMAT_ES, input: 'index.mjs', outputDir: DIR_ESM }),
buildConfig({ format: FORMAT_CJS }),
buildConfig({
format: FORMAT_ES,
input: 'index.mjs',
name: 'mjs',
outputDir: DIR_ESM,
}),
buildConfig({ format: FORMAT_CJS, name: FORMAT_CJS }),
buildConfig({ name: ENV_DEVELOPMENT }),
/* this bundle will be deprecated in the next major */
buildConfig({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"scripts": {
"build": "node ./scripts/buildAll",
"prettier-watch": "onchange '**/*.js' '**/*.json' -- prettier --write {{changed}}",
"test": "jest --projects ./packages/*/ --i",
"test": "jest --projects ./packages/*/",
"lint": "eslint . --ignore-path .gitignore"
},
"husky": {
Expand Down
4 changes: 2 additions & 2 deletions packages/vest/docs/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const { test, enforce } = vest;
Depending on your node version and used flag, your require statement might default to Vest's minified es5 bundle. If you want to make sure to use the non-minified es6 commonjs bundle, you can require it directly.

```js
const vest = require('vest/vest.cjs');
const vest = require('vest/vest.cjs.js');
const { test, enforce } = vest;
```

Expand All @@ -30,7 +30,7 @@ const { test, enforce } = vest;
If you want to explicitly load Vest's esm module, you can import it directly:

```js
import vest, { test } from 'vest/esm/vest.mjs';
import vest, { test } from 'vest/esm/vest.mjs.js';
```

### Node 14
Expand Down
8 changes: 4 additions & 4 deletions packages/vest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"description": "Validation Test",
"main": "./vest.es5.js",
"browser": "./vest.es5.js",
"module": "./esm/vest.mjs",
"module": "./esm/vest.mjs.js",
"exports": {
".": {
"browser": "./vest.es5.js",
"import": "./esm/vest.mjs",
"require": "./vest.cjs",
"node": "./vest.cjs",
"import": "./esm/vest.mjs.js",
"require": "./vest.cjs.js",
"node": "./vest.cjs.js",
"default": "./vest.es5.js"
},
"./vest.es5.js": "./vest.es5.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,56 @@ Object {
},
}
`;

exports[`Stateful behavior Should have all fields 6`] = `
Object {
"field_1": Object {
"errorCount": 1,
"errors": Array [
"field_statement_1",
],
"testCount": 1,
"warnCount": 0,
},
"field_2": Object {
"errorCount": 1,
"errors": Array [
"field_statement_2",
],
"testCount": 1,
"warnCount": 0,
},
"field_3": Object {
"errorCount": 0,
"testCount": 1,
"warnCount": 0,
},
"field_4": Object {
"errorCount": 0,
"testCount": 2,
"warnCount": 1,
"warnings": Array [
"field_statement_4",
],
},
"field_5": Object {
"errorCount": 2,
"errors": Array [
"field_statement_5",
"field_statement_6",
],
"testCount": 2,
"warnCount": 0,
},
"field_6": Object {
"errorCount": 0,
"testCount": 1,
"warnCount": 0,
},
"field_7": Object {
"errorCount": 0,
"testCount": 1,
"warnCount": 0,
},
}
`;
50 changes: 50 additions & 0 deletions packages/vest/src/spec/__snapshots__/integration.base.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,53 @@ Object {
"warnCount": 1,
}
`;

exports[`Base behavior Should produce correct validation result 6`] = `
Object {
"done": [Function],
"errorCount": 2,
"getErrors": [Function],
"getErrorsByGroup": [Function],
"getWarnings": [Function],
"getWarningsByGroup": [Function],
"groups": Object {},
"hasErrors": [Function],
"hasErrorsByGroup": [Function],
"hasWarnings": [Function],
"hasWarningsByGroup": [Function],
"name": "suite_name",
"testCount": 5,
"tests": Object {
"field_1": Object {
"errorCount": 1,
"errors": Array [
"field_statement_1",
],
"testCount": 1,
"warnCount": 0,
},
"field_2": Object {
"errorCount": 1,
"errors": Array [
"field_statement_2",
],
"testCount": 1,
"warnCount": 0,
},
"field_3": Object {
"errorCount": 0,
"testCount": 1,
"warnCount": 0,
},
"field_4": Object {
"errorCount": 0,
"testCount": 2,
"warnCount": 1,
"warnings": Array [
"field_statement_4",
],
},
},
"warnCount": 1,
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -679,3 +679,139 @@ Object {
"warnCount": 0,
}
`;

exports[`Stateful async tests Merges skipped validations from previous suite 16`] = `
Object {
"done": [Function],
"errorCount": 1,
"getErrors": [Function],
"getErrorsByGroup": [Function],
"getWarnings": [Function],
"getWarningsByGroup": [Function],
"groups": Object {},
"hasErrors": [Function],
"hasErrorsByGroup": [Function],
"hasWarnings": [Function],
"hasWarningsByGroup": [Function],
"name": "suite_name",
"testCount": 5,
"tests": Object {
"field_1": Object {
"errorCount": 1,
"errors": Array [
"field_statement_1",
],
"testCount": 1,
"warnCount": 0,
},
"field_2": Object {
"errorCount": 0,
"testCount": 2,
"warnCount": 0,
},
"field_3": Object {
"errorCount": 0,
"testCount": 2,
"warnCount": 0,
},
},
"warnCount": 0,
}
`;

exports[`Stateful async tests Merges skipped validations from previous suite 17`] = `
Object {
"errorCount": 2,
"getErrors": [Function],
"getErrorsByGroup": [Function],
"getWarnings": [Function],
"getWarningsByGroup": [Function],
"groups": Object {},
"hasErrors": [Function],
"hasErrorsByGroup": [Function],
"hasWarnings": [Function],
"hasWarningsByGroup": [Function],
"name": "suite_name",
"testCount": 5,
"tests": Object {
"field_1": Object {
"errorCount": 1,
"errors": Array [
"field_statement_1",
],
"testCount": 1,
"warnCount": 0,
},
"field_2": Object {
"errorCount": 0,
"testCount": 2,
"warnCount": 0,
},
"field_3": Object {
"errorCount": 1,
"testCount": 2,
"warnCount": 0,
},
},
"warnCount": 0,
}
`;

exports[`Stateful async tests Merges skipped validations from previous suite 18`] = `
Object {
"errorCount": 5,
"getErrors": [Function],
"getErrorsByGroup": [Function],
"getWarnings": [Function],
"getWarningsByGroup": [Function],
"groups": Object {
"group": Object {
"field_1": Object {
"errorCount": 1,
"testCount": 1,
"warnCount": 0,
},
"field_4": Object {
"errorCount": 1,
"testCount": 1,
"warnCount": 0,
},
},
},
"hasErrors": [Function],
"hasErrorsByGroup": [Function],
"hasWarnings": [Function],
"hasWarningsByGroup": [Function],
"name": "suite_name",
"testCount": 7,
"tests": Object {
"field_1": Object {
"errorCount": 2,
"errors": Array [
"field_statement_1",
],
"testCount": 2,
"warnCount": 0,
},
"field_2": Object {
"errorCount": 1,
"errors": Array [
"rejection_message_1",
],
"testCount": 2,
"warnCount": 0,
},
"field_3": Object {
"errorCount": 1,
"testCount": 2,
"warnCount": 0,
},
"field_4": Object {
"errorCount": 1,
"testCount": 1,
"warnCount": 0,
},
},
"warnCount": 0,
}
`;
Loading

0 comments on commit f078398

Please sign in to comment.