Skip to content

[WIP] Fix test to check for CSV file existence#50

Closed
Copilot wants to merge 1 commit intomainfrom
copilot/fix-csv-file-existence-check
Closed

[WIP] Fix test to check for CSV file existence#50
Copilot wants to merge 1 commit intomainfrom
copilot/fix-csv-file-existence-check

Conversation

Copy link
Contributor

Copilot AI commented Dec 4, 2025

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.

Original prompt

Issue

The packages/pine2ts/tests/regression/indicator-regression.test.ts test is failing in CI because it tries to load a CSV file that doesn't exist in the repository:

Error: ENOENT: no such file or directory, open '/home/runner/work/oakscriptJS/oakscriptJS/tests/SP_SPX, 1D_649c1.csv'

The test at line 25-26 does:

const csvPath = join(__dirname, '../../../../tests/SP_SPX, 1D_649c1.csv');
const csvContent = readFileSync(csvPath, 'utf-8');

But the file tests/SP_SPX, 1D_649c1.csv doesn't exist in the repository.

Solution

Update packages/pine2ts/tests/regression/indicator-regression.test.ts to:

  1. Check if the CSV file exists before trying to read it
  2. If the file doesn't exist, skip the entire test suite with a warning message (similar to how the pinesuite test skips when PINESUITE_TOKEN is not set)
  3. Use describe.skip() or describe.skipIf() pattern to gracefully skip the tests

The fix should:

  • Use existsSync from fs to check if the file exists
  • If file doesn't exist, log a warning and skip all tests in the describe block
  • Not fail the CI when the reference data file is missing

Example pattern:

import { existsSync, readFileSync } from 'fs';

const csvPath = join(__dirname, '../../../../tests/SP_SPX, 1D_649c1.csv');
const csvExists = existsSync(csvPath);

if (!csvExists) {
  console.warn('⚠️  Reference CSV file not found. Skipping indicator regression tests.');
  console.warn(`   Expected: ${csvPath}`);
}

describe.skipIf(!csvExists)('Indicator Regression Tests', () => {
  // ... rest of tests
});

This ensures CI passes when the reference data isn't available, while still running the tests when it is.

This pull request was created as a result of the following prompt from Copilot chat.

Issue

The packages/pine2ts/tests/regression/indicator-regression.test.ts test is failing in CI because it tries to load a CSV file that doesn't exist in the repository:

Error: ENOENT: no such file or directory, open '/home/runner/work/oakscriptJS/oakscriptJS/tests/SP_SPX, 1D_649c1.csv'

The test at line 25-26 does:

const csvPath = join(__dirname, '../../../../tests/SP_SPX, 1D_649c1.csv');
const csvContent = readFileSync(csvPath, 'utf-8');

But the file tests/SP_SPX, 1D_649c1.csv doesn't exist in the repository.

Solution

Update packages/pine2ts/tests/regression/indicator-regression.test.ts to:

  1. Check if the CSV file exists before trying to read it
  2. If the file doesn't exist, skip the entire test suite with a warning message (similar to how the pinesuite test skips when PINESUITE_TOKEN is not set)
  3. Use describe.skip() or describe.skipIf() pattern to gracefully skip the tests

The fix should:

  • Use existsSync from fs to check if the file exists
  • If file doesn't exist, log a warning and skip all tests in the describe block
  • Not fail the CI when the reference data file is missing

Example pattern:

import { existsSync, readFileSync } from 'fs';

const csvPath = join(__dirname, '../../../../tests/SP_SPX, 1D_649c1.csv');
const csvExists = existsSync(csvPath);

if (!csvExists) {
  console.warn('⚠️  Reference CSV file not found. Skipping indicator regression tests.');
  console.warn(`   Expected: ${csvPath}`);
}

describe.skipIf(!csvExists)('Indicator Regression Tests', () => {
  // ... rest of tests
});

This ensures CI passes when the reference data isn't available, while still running the tests when it is.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants