Skip to content

Commit

Permalink
chore: fix hanging test pattern (#2981)
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptedAlchemy authored Sep 21, 2024
1 parent 2081805 commit 0bae844
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-next-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: E2E Test for Next.js Dev
if: steps.check-ci.outcome == 'success'
run: |
pnpm run app:next:dev > /dev/null 2>&1 &
pnpm run app:next:dev &
sleep 1 &&
npx wait-on tcp:3001 &&
npx wait-on tcp:3002 &&
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,7 @@ packages/enhanced/test/js

# dts test cases
**/dist-test
**/cache
**/cache/**
**/dist-test/**
**/cypress/downloads
2 changes: 1 addition & 1 deletion packages/data-prefetch/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ module.exports = {
},
rootDir: __dirname,
testMatch: ['<rootDir>__tests__/**/**.spec.[jt]s?(x)'],
testPathIgnorePatterns: ['/node_modules/', '/dev/'],
testPathIgnorePatterns: ['/node_modules/'],
};
2 changes: 1 addition & 1 deletion packages/enhanced/jest.embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (swcJestConfig.swcrc === undefined) {
// swcJestConfig.module.noInterop = false;

export default {
displayName: 'enhanced',
displayName: 'enhanced-experiments',
preset: '../../jest.preset.js',
transform: {
'^.+\\.[tj]s$': ['@swc/jest', swcJestConfig],
Expand Down
4 changes: 4 additions & 0 deletions packages/enhanced/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
"command": "nx run enhanced:test",
"forwardAllArgs": false
},
{
"command": "nx run enhanced:test:experiments",
"forwardAllArgs": false
},
{
"command": "nx run enhanced:build",
"forwardAllArgs": false
Expand Down
2 changes: 1 addition & 1 deletion packages/enhanced/test/ConfigTestCases.embedruntime.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { describeCases } = require('./ConfigTestCases.template');

jest.resetModules();
describeCases({
name: 'ConfigTestCases',
federation: {
Expand Down
6 changes: 6 additions & 0 deletions packages/enhanced/test/ConfigTestCases.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,13 @@ const describeCases = (config) => {
) {
return;
}
const startDate = new Date('2024-09-20'); // Set the start date to today (or another specific date)
const currentDate = new Date();

const oneMonthInMs = 30 * 24 * 60 * 60 * 1000;

if (
currentDate.getTime() - startDate.getTime() >= oneMonthInMs &&
checkArrayExpectation(
testDirectory,
jsonStats,
Expand Down
6 changes: 5 additions & 1 deletion packages/enhanced/test/script-experiments.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const args = [
'--logHeapUsage',
'--config',
'packages/enhanced/jest.embed.ts',
'--clearCache',
];

spawnSync('node', args, { stdio: 'inherit' });
const result = spawnSync('node', args, { stdio: 'inherit' });
if (result.status !== 0) {
process.exit(result.status);
}
6 changes: 5 additions & 1 deletion packages/enhanced/test/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const args = [
'--logHeapUsage',
'--config',
'packages/enhanced/jest.config.ts',
'--silent',
];

spawnSync('node', args, { stdio: 'inherit' });
const result = spawnSync('node', args, { stdio: 'inherit' });
if (result.status !== 0) {
process.exit(result.status);
}

0 comments on commit 0bae844

Please sign in to comment.