test: add jest and simple spec

This commit is contained in:
Igor Randjelovic
2020-11-14 14:14:36 +01:00
parent 49a47fef2a
commit e704f744b7
5 changed files with 62 additions and 23 deletions

View File

@ -0,0 +1,13 @@
import * as webpack from '@nativescript/webpack';
describe('@nativescript/webpack', () => {
it('exports base configs', () => {
expect(webpack.angularConfig).toBeInstanceOf(Function);
expect(webpack.baseConfig).toBeInstanceOf(Function);
expect(webpack.javascriptConfig).toBeInstanceOf(Function);
expect(webpack.reactConfig).toBeInstanceOf(Function);
expect(webpack.svelteConfig).toBeInstanceOf(Function);
expect(webpack.typescriptConfig).toBeInstanceOf(Function);
expect(webpack.vueConfig).toBeInstanceOf(Function);
});
});

View File

@ -0,0 +1,7 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
moduleNameMapper: {
'^@nativescript/webpack$': '<rootDir>/src'
}
};

View File

@ -5,9 +5,17 @@
"main": "index.js", "main": "index.js",
"license": "Apache-2.0", "license": "Apache-2.0",
"scripts": { "scripts": {
"build": "echo todo" "build": "echo todo",
"test": "jest"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^26.0.15",
"jest": "^26.6.3",
"ts-jest": "^26.4.4",
"typescript": "^4.0.5",
"webpack": "^5.4.0" "webpack": "^5.4.0"
},
"dependencies": {
"webpack-chain": "^6.5.1"
} }
} }

View File

@ -1,15 +1,18 @@
import base from './base'; import base from './base';
import Config from 'webpack-chain';
// todo: add base configuration for vue // todo: add base configuration for vue
export default function (env) { export default function (env) {
const config = base(env); const config = new Config().merge(base(env));
// todo: we may want to use webpack-chain internally // todo: we may want to use webpack-chain internally
// to avoid "trying to read property x of undefined" type of issues // to avoid "trying to read property x of undefined" type of issues
/*
config.module.rules.push({ config.module.rules.push({
test: /.vue$/, test: /.vue$/,
use: [], use: [],
}); });
*/
return {}; return {};
} }

View File

@ -7,13 +7,21 @@
"declaration": true, "declaration": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"lib": [ "es2017" ], "lib": [
"es2017"
],
"sourceMap": true, "sourceMap": true,
"skipLibCheck": true, "skipLibCheck": true,
"skipDefaultLibCheck": true, "skipDefaultLibCheck": true,
"diagnostics": true "diagnostics": true,
"paths": {
"@nativescript/webpack": [
"src"
]
},
"allowSyntheticDefaultImports": true
}, },
"exclude": [ "exclude": [
"node_modules", "node_modules"
] ]
} }