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({ /*
test: /.vue$/, config.module.rules.push({
use: [], test: /.vue$/,
}); use: [],
});
*/
return {}; return {};
} }

View File

@ -1,19 +1,27 @@
{ {
"compilerOptions": { "compilerOptions": {
"rootDir": ".", "rootDir": ".",
"baseUrl": ".", "baseUrl": ".",
"target": "es2015", "target": "es2015",
"module": "commonjs", "module": "commonjs",
"declaration": true, "declaration": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"lib": [ "es2017" ], "lib": [
"sourceMap": true, "es2017"
"skipLibCheck": true, ],
"skipDefaultLibCheck": true, "sourceMap": true,
"diagnostics": true "skipLibCheck": true,
}, "skipDefaultLibCheck": true,
"exclude": [ "diagnostics": true,
"node_modules", "paths": {
] "@nativescript/webpack": [
"src"
]
},
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules"
]
} }