Skip to content

Commit

Permalink
fix(react): fix next unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Mar 15, 2023
1 parent 4690444 commit 281fe31
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions packages/next/src/utils/config.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import 'nx/src/utils/testing/mock-fs';
import { createWebpackConfig } from './config';
import { NextBuildBuilderOptions } from '@nrwl/next';
import { dirname } from 'path';
import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin';

import { PHASE_PRODUCTION_BUILD } from './constants';

jest.mock('@nrwl/webpack', () => ({
createCopyPlugin: () => {},
}));
jest.mock('@nrwl/webpack', () => ({}));
jest.mock('tsconfig-paths-webpack-plugin');
jest.mock('next/dist/server/config', () => ({
__esModule: true,
Expand Down Expand Up @@ -57,17 +51,28 @@ describe('Next.js webpack config builder', () => {
});
});

it('should set the rules', () => {
it('should add rules for ts', () => {
const webpackConfig = createWebpackConfig('/root', 'apps/wibble', []);

const config = webpackConfig(
{ resolve: { alias: {} }, module: { rules: [] }, plugins: [] },
{
resolve: { alias: {} },
module: {
rules: [
{
test: /\.*.ts/,
loader: 'some-ts-loader',
},
],
},
plugins: [],
},
{ defaultLoaders: {} }
);

// not much value in checking what they are
// just check they get added
expect(config.module.rules.length).toBe(1);
expect(config.module.rules.length).toBe(2);
});
});
});

0 comments on commit 281fe31

Please sign in to comment.