Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests failing false positive #64

Open
Amndeep7 opened this issue Jul 31, 2024 · 0 comments
Open

Tests failing false positive #64

Amndeep7 opened this issue Jul 31, 2024 · 0 comments

Comments

@Amndeep7
Copy link
Contributor

https://github.com/mitre/saf_action/actions/runs/10185845654/job/28176277275

Output:

> [email protected] test
> jest

  ●  process.exit called with "1"

       [6](https://github.com/mitre/saf_action/actions/runs/10185845654/job/28176277275#step:3:7) |     let inputFilePath = path.resolve('./test/sample_data/red_hat_good.json');
       [7](https://github.com/mitre/saf_action/actions/runs/10185845654/job/28176277275#step:3:8) |     process.env['INPUT_COMMAND_STRING'] = `view summary -i ${inputFilePath}`;
    >  [8](https://github.com/mitre/saf_action/actions/runs/10185845654/job/28176277275#step:3:9) |     await saf_action({safCLIPath: "./node_modules/@mitre/saf/lib/index.js"});
         |     ^
       [9](https://github.com/mitre/saf_action/actions/runs/10185845654/job/28176277275#step:3:10) |     delete process.env['INPUT_COMMAND_STRING'];
      [10](https://github.com/mitre/saf_action/actions/runs/10185845654/job/28176277275#step:3:11) |   });
      11 |   it('should run SAF with a colon topic separator in the command string', async () => {

      at Summary.run (node_modules/@mitre/saf/src/commands/view/summary.ts:151:15)

With additional debugging:

amann saf_action ❯❯❯ npm run test

> [email protected] test
> jest

  console.log
    entered test

      at Object.log (test/index.test.js:6:13)

  console.log
    path: /Users/amann/work/saf/saf_action/test/sample_data/red_hat_good.json

      at Object.log (test/index.test.js:8:13)

  console.log
    TypeError: Cannot read properties of undefined (reading 'flatten')

      at Summary.run (node_modules/@mitre/saf/src/commands/view/summary.ts:145:7)

  ●  process.exit called with "1"

I recently made changes to how we import the flat package in the SAF CLI to do a dynamic import. This didn't cause any problems when running the SAF CLI by hand, nor does it cause problems when the action is used in a live setting (both in the examples workflow here as well as in a branch I made on the rhel8 inspec repo). I feel like it's just yet another weirdness with how the testing framework interacts with things that in this case is not playing well with the async (and not really awaited) nature of how we are currently dynamically importing things.

Long term solution is to move everything to ESM. In the meantime, this will fail.

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

No branches or pull requests

1 participant