Skip to content

Commit

Permalink
chore: update tests to accept fake cdn assets
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyperkid123 committed Apr 9, 2024
1 parent e496928 commit 213422a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ Thumbs.db
.nx
.webpack-cache
.vscode
.cdn-cache
6 changes: 5 additions & 1 deletion dev-script.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const concurrently = require('concurrently')
const path = require('path')
const fs = require('fs')
const { execSync } = require('child_process')

const cdnPath = path.resolve(__dirname, './federation-cdn-mock')
const cdnAssetsPath = path.resolve(__dirname, './federation-cdn-mock/distx')
const cdnAssetsPath = path.resolve(__dirname, './federation-cdn-mock/dist')

try {
fs.statSync(cdnAssetsPath)
Expand All @@ -12,6 +13,9 @@ try {
fs.mkdirSync(cdnAssetsPath)
}

// ensure the deps exist before we start the servers
execSync('npm run build', { cwd: cdnPath, stdio: 'inherit'})

concurrently(
[{
cwd: cdnPath,
Expand Down
1 change: 1 addition & 0 deletions examples/test-app-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"e2e": {
"executor": "@nx/cypress:cypress",
"options": {
"skipServe": true,
"cypressConfig": "examples/test-app-e2e/cypress.config.ts",
"testingType": "e2e",
"devServerTarget": "test-app:serve",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ describe('Module error loading handling', () => {
cy.visit('http://localhost:4200/legacy');

// intercept webpack chunk and return 500 response
cy.intercept('GET', '/src_modules_preLoad_tsx.js', {
cy.intercept('GET', 'http://localhost:8001/exposed-./PreLoadedModule.js', {
statusCode: 500,
});

Expand All @@ -16,7 +16,7 @@ describe('Module error loading handling', () => {
cy.get('#render-preload-module').click();
cy.wait(1000);

cy.contains(`Loading chunk src_modules_preLoad_tsx failed.`).should('exist');
cy.contains(`Loading chunk exposed-./PreLoadedModule failed.`).should('exist');
});

it('should handle runtime module error', () => {
Expand Down
3 changes: 2 additions & 1 deletion federation-cdn-mock/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ function init() {
/** @type { import("webpack").Configuration } */
const config = {
entry: {},
cache: { type: 'filesystem', cacheDirectory: resolve(__dirname, '.cdn-cache')},
output: {
publicPath: 'auto',
},
mode: 'production',
mode: 'development',
plugins: [TestSDKPLugin],
module: {
rules: [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dev": "node dev-script.js",
"test:unit": "nx run-many -t test",
"test:unit:affected": "nx affected -t test",
"test:e2e": "nx run test-app-e2e:e2e",
"test:e2e": "concurrently \"npm run dev\" \"nx run test-app-e2e:e2e\"",
"test": "npm-run-all --parallel test:*",
"build": "nx run-many -t build",
"lint": "nx run-many -t lint",
Expand Down

0 comments on commit 213422a

Please sign in to comment.