Skip to content

Commit a808b7f

Browse files
committed
chore: fix some test and types related stuff
1 parent 2b8b2df commit a808b7f

File tree

10 files changed

+50
-16
lines changed

10 files changed

+50
-16
lines changed

packages/babel-preset-base/.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = {
55
files: ['**/*.ts', '**/*.tsx'],
66
extends: ['@wpackio/eslint-config/ts'],
77
parserOptions: {
8-
project: './tsconfig.json',
8+
project: './tsconfig.eslint.json',
99
tsconfigRootDir: __dirname,
1010
},
1111
settings: {

packages/babel-preset-base/__tests__/index.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
/* eslint-disable @typescript-eslint/no-var-requires */
2+
/* eslint-disable jest/no-mocks-import */
13
import { mockedApi } from '../__mocks__/@babel/helper-plugin-utils';
4+
25
const wpwBabelPresetBase = require('../src/index');
36

7+
declare const expect: jest.Expect;
8+
49
describe('@wpackio/babel-preset-base', () => {
510
test('checks for babel 7', () => {
611
wpwBabelPresetBase({}, undefined, __dirname);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"outDir": "./lib" /* Redirect output structure to the directory. */,
5+
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
6+
},
7+
"exclude": [
8+
"__mocks__/**",
9+
"lib/**"
10+
]
11+
}

packages/entrypoint/.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = {
55
files: ['**/*.ts', '**/*.tsx'],
66
extends: ['@wpackio/eslint-config/ts'],
77
parserOptions: {
8-
project: './tsconfig.json',
8+
project: './tsconfig.eslint.json',
99
tsconfigRootDir: __dirname,
1010
},
1111
settings: {
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1+
// this import is to make this file a module so that we can override expect
2+
import { IGNORE } from '../src/module';
3+
4+
declare const expect: jest.Expect;
5+
16
describe('entrypoint', () => {
27
test('sets __webpack_public_path__ from WPACKIO(webpack.DefinePlugin)', () => {
38
const oldGlobal = global;
49
// tslint:disable-next-line:no-any
5-
expect((global as { [x: string]: any }).__webpack_public_path__).toBe(
6-
''
7-
);
10+
// eslint-disable-next-line no-underscore-dangle
11+
expect((global as { [x: string]: any }).__webpack_public_path__).toBe('');
812
// Require our package
13+
// eslint-disable-next-line global-require
914
require('../src/index');
1015
// tslint:disable-next-line:no-any
16+
// eslint-disable-next-line no-underscore-dangle
1117
expect((global as { [x: string]: any }).__webpack_public_path__).toBe(
1218
'/biz/baz'
1319
);
1420
// tslint:disable-next-line:no-any
21+
// eslint-disable-next-line no-global-assign
1522
(global as any) = oldGlobal;
1623
});
1724
});

packages/entrypoint/src/module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const IGNORE = 'ignore';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"outDir": "./lib" /* Redirect output structure to the directory. */,
5+
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
6+
},
7+
"exclude": [
8+
"__mocks__/**",
9+
"lib/**"
10+
]
11+
}

packages/scripts/__tests__/config/CreateWebpackConfig.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ jest.mock('webpack-merge');
1010

1111
beforeEach(initConfig);
1212

13+
declare const expect: jest.Expect;
14+
1315
describe('CreateWebpackConfig', () => {
1416
test('instantiates', () => {
1517
const cwc = new CreateWebpackConfig(
@@ -100,9 +102,7 @@ describe('CreateWebpackConfig', () => {
100102
const config = cwc.getWebpackConfig();
101103
expect(mocker).toHaveBeenCalledTimes(1);
102104
expect(config).toHaveProperty('testSuccess');
103-
expect(
104-
(config as { testSuccess: boolean }).testSuccess
105-
).toBeTruthy();
105+
expect((config as { testSuccess: boolean }).testSuccess).toBeTruthy();
106106
});
107107
test('calls merge when files[n].webpackConfig is an object', () => {
108108
const multiProjectConfig: ProjectConfig = {

packages/scripts/__tests__/config/WebpackConfigHelper.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ declare const expect: jest.Expect;
2222

2323
beforeAll(() => {
2424
// @ts-ignore
25-
// eslint-disable-next-line new-cap
25+
// eslint-disable-next-line babel/new-cap
2626
global.Date = jest.fn(() => new realDate(currentDate.toISOString()));
2727
Object.assign(Date, realDate);
2828
});

packages/scripts/__tests__/config/getProjectAndServerConfig.spec.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {
66
} from '../../src/config/getProjectAndServerConfig';
77
import { ProjectConfig } from '../../src/config/project.config.default';
88

9+
declare const expect: jest.Expect;
10+
911
const pathToDummyRight = path.resolve(
1012
__dirname,
1113
'../helpers/dummyConfigRight.js'
@@ -82,16 +84,13 @@ describe('getProjectAndServerConfig', () => {
8284
});
8385
});
8486
test('looks for default file under cwd', () => {
85-
const {
86-
projectConfigPath,
87-
serverConfigPath,
88-
} = getProjectAndServerConfig(validCwd);
87+
const { projectConfigPath, serverConfigPath } = getProjectAndServerConfig(
88+
validCwd
89+
);
8990
expect(projectConfigPath).toBe(
9091
path.resolve(validCwd, 'wpackio.project.js')
9192
);
92-
expect(serverConfigPath).toBe(
93-
path.resolve(validCwd, 'wpackio.server.js')
94-
);
93+
expect(serverConfigPath).toBe(path.resolve(validCwd, 'wpackio.server.js'));
9594
});
9695
});
9796

0 commit comments

Comments
 (0)