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

runSnapshotTests throws an error on Windows when additional path segments are specified in path.resolve arguments #4

Open
melquan opened this issue Feb 24, 2020 · 0 comments

Comments

@melquan
Copy link

melquan commented Feb 24, 2020

Version: 1.1.1

Details

inferName throws an error at https://github.com/marko-js/fixture-snapshots/blob/master/src/index.ts#L129 when specifying the following in Windows:

runSnapshotTests(path.resolve(__dirname, '../'), { fixtureDir: 'test/fixtures' });

Expected Behavior

Account for Windows path delimiter and not throw an error.

Enhancement request: Actually would hope that we could enhance this to only have to do runSnapshotTests(); and it would detect the current component's fixtures files to run the snapshot tests, like we were able to do in marko-tester by just running testFixtures();.

Actual Behavior

Throws an error:

TypeError: Cannot read property '2' of null

 at inferName (node_modules/@marko/fixture-snapshots/src/index.ts:130:32)
      at findComponentFixtures (node_modules/@marko/fixture-snapshots/src/index.ts:31:25)
      at node_modules/@marko/fixture-snapshots/src/index.ts:87:14
          at Array.map (<anonymous>)
      at Object.findProjectFixtures (node_modules/@marko/fixture-snapshots/src/index.ts:85:6)
      at runSnapshotTests (node_modules/@marko/fixture-snapshots/src/jest.ts:11:3)

Possible Fix

Update that line to:

var match = /\\([^\\]+)\\([^\\]+)\.marko$/.exec(p);
Additional Info

Your Environment

  • Environment name and version: Node.js 10.19.0
  • Operating System and version: Windows 10
  • Link to your project: Please ping me in Slack for this.

Steps to Reproduce

  1. Installed @marko/fixture-snapshots.
  2. Created a test component with an ebay-button and some text that's shown when the button is clicked.
  3. Added the following to my test file:
const path = require('path');
const runSnapshotTests = require('@marko/fixture-snapshots/jest').default;

runSnapshotTests(path.resolve(__dirname, '../'), { fixtureDir: 'test/fixtures' });
  1. Ran jest -u.

Stack Trace

See above in Actual Behavior section.

@melquan melquan changed the title runSnapshotTests throws an error on Windows with additional path segments specified in path.resolve runSnapshotTests throws an error on Windows when additional path segments are specified in path.resolve arguments Feb 24, 2020
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