Skip to content

Commit

Permalink
Fix Angular tests for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Marklb committed Dec 4, 2021
1 parent b39cfdc commit e432ea0
Showing 1 changed file with 110 additions and 34 deletions.
144 changes: 110 additions & 34 deletions app/angular/src/server/framework-preset-angular-cli.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable jest/no-interpolation-in-snapshots */
import p from 'path';
import { Configuration } from 'webpack';
import { logger } from '@storybook/node-logger';
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
Expand Down Expand Up @@ -263,18 +264,18 @@ describe('framework-preset-angular-cli', () => {

expect(webpackFinalConfig.resolve.modules).toEqual([
...baseWebpackConfig.resolve.modules,
`${workspaceRoot}/src`,
p.resolve(`${workspaceRoot}/src`).replace(/\\/g, '/'),
]);
});

it('should replace webpack "resolve.plugins"', async () => {
it('should replace webpack resolve.plugins', async () => {
const baseWebpackConfig = newWebpackConfiguration();
const webpackFinalConfig = await webpackFinal(baseWebpackConfig, options);

expect(webpackFinalConfig.resolve.plugins).toMatchInlineSnapshot(`
Array [
TsconfigPathsPlugin {
"absoluteBaseUrl": "${workspaceRoot}/src/",
"absoluteBaseUrl": "${p.normalize(`${workspaceRoot}/src/`).replace(/\\/g, '\\\\')}",
"baseUrl": "./",
"extensions": Array [
".ts",
Expand Down Expand Up @@ -307,8 +308,8 @@ describe('framework-preset-angular-cli', () => {
...baseWebpackConfig,
entry: [
...(baseWebpackConfig.entry as any[]),
`${workspaceRoot}/src/styles.css`,
`${workspaceRoot}/src/styles.scss`,
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
module: { ...baseWebpackConfig.module, rules: expect.anything() },
plugins: expect.anything(),
Expand All @@ -328,42 +329,66 @@ describe('framework-preset-angular-cli', () => {

expect(webpackFinalConfig.module.rules).toEqual([
{
exclude: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
exclude: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.css$/,
use: expect.anything(),
},
{
exclude: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
exclude: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.scss$|\.sass$/,
use: expect.anything(),
},
{
exclude: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
exclude: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.less$/,
use: expect.anything(),
},
{
exclude: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
exclude: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.styl$/,
use: expect.anything(),
},
{
include: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
include: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.css$/,
use: expect.anything(),
},
{
include: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
include: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.scss$|\.sass$/,
use: expect.anything(),
},
{
include: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
include: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.less$/,
use: expect.anything(),
},
{
include: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
include: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.styl$/,
use: expect.anything(),
},
Expand Down Expand Up @@ -398,8 +423,8 @@ describe('framework-preset-angular-cli', () => {
...baseWebpackConfig,
entry: [
...(baseWebpackConfig.entry as any[]),
`${workspaceRoot}/src/styles.css`,
`${workspaceRoot}/src/styles.scss`,
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
module: { ...baseWebpackConfig.module, rules: expect.anything() },
plugins: expect.anything(),
Expand All @@ -419,42 +444,66 @@ describe('framework-preset-angular-cli', () => {

expect(webpackFinalConfig.module.rules).toEqual([
{
exclude: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
exclude: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.css$/,
use: expect.anything(),
},
{
exclude: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
exclude: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.scss$|\.sass$/,
use: expect.anything(),
},
{
exclude: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
exclude: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.less$/,
use: expect.anything(),
},
{
exclude: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
exclude: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.styl$/,
use: expect.anything(),
},
{
include: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
include: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.css$/,
use: expect.anything(),
},
{
include: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
include: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.scss$|\.sass$/,
use: expect.anything(),
},
{
include: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
include: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.less$/,
use: expect.anything(),
},
{
include: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
include: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.styl$/,
use: expect.anything(),
},
Expand All @@ -476,8 +525,8 @@ describe('framework-preset-angular-cli', () => {
...baseWebpackConfig,
entry: [
...(baseWebpackConfig.entry as any[]),
`${workspaceRoot}/src/styles.css`,
`${workspaceRoot}/src/styles.scss`,
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
module: { ...baseWebpackConfig.module, rules: expect.anything() },
plugins: expect.anything(),
Expand All @@ -501,42 +550,66 @@ describe('framework-preset-angular-cli', () => {

expect(webpackFinalConfig.module.rules).toEqual([
{
exclude: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
exclude: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.css$/,
use: expect.anything(),
},
{
exclude: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
exclude: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.scss$|\.sass$/,
use: expect.anything(),
},
{
exclude: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
exclude: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.less$/,
use: expect.anything(),
},
{
exclude: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
exclude: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.styl$/,
use: expect.anything(),
},
{
include: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
include: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.css$/,
use: expect.anything(),
},
{
include: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
include: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.scss$|\.sass$/,
use: expect.anything(),
},
{
include: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
include: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.less$/,
use: expect.anything(),
},
{
include: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
include: [
p.resolve(`${workspaceRoot}/src/styles.css`),
p.resolve(`${workspaceRoot}/src/styles.scss`),
],
test: /\.styl$/,
use: expect.anything(),
},
Expand Down Expand Up @@ -699,7 +772,10 @@ describe('framework-preset-angular-cli', () => {

expect(webpackFinalConfig).toEqual({
...baseWebpackConfig,
entry: [...(baseWebpackConfig.entry as any[]), `${workspaceRoot}/src/styles.css`],
entry: [
...(baseWebpackConfig.entry as any[]),
p.resolve(`${workspaceRoot}/src/styles.css`),
],
module: { ...baseWebpackConfig.module, rules: expect.anything() },
plugins: expect.anything(),
resolve: {
Expand Down

0 comments on commit e432ea0

Please sign in to comment.