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

Functions exported from global data have NaN value at compile time #2

Open
Zearin opened this issue Mar 26, 2024 · 2 comments
Open
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Zearin
Copy link
Owner

Zearin commented Mar 26, 2024

I added a new test case (test/test-plugin-data-functions.js) to see whether the global data files would allow an exported function to be used by Pug at compile-time.

Nope!

Although the key (daFunc) was present in the cascade data passed to the anonymous inner async function, its value was NaN for reasons I can’t figure.

@Zearin Zearin added bug Something isn't working help wanted Extra attention is needed labels Mar 26, 2024
@Aankhen
Copy link
Contributor

Aankhen commented Apr 24, 2024

What should I do to get the tests running normally? Using main (39e7e9d), I see these errors with npm test:

✖ SCENARIO: Global Data (0.5592ms)
  TypeError [ERR_INVALID_ARG_TYPE]: The "paths[0]" argument must be of type string. Received undefined
      at new NodeError (node:internal/errors:405:5)
      at validateString (node:internal/validators:162:11)
      at Object.resolve (node:path:167:9)
      at SuiteContext.<anonymous> (file:///C:/Media/src/eleventy-plugin-pug/test/test-plugin-data-access.js:19:41)
      at Suite.runInAsyncScope (node:async_hooks:203:9)
      at new Suite (node:internal/test_runner/test:773:24)
      at Test.createSubtest (node:internal/test_runner/test:386:18)
      at run (node:internal/test_runner/harness:208:28)
      at test (node:internal/test_runner/harness:215:39)
      at file:///C:/Media/src/eleventy-plugin-pug/test/test-plugin-data-access.js:18:1 {
    code: 'ERR_INVALID_ARG_TYPE'
  }

✖ SCENARIO: Global Data Function (0.5525ms)
  TypeError [ERR_INVALID_ARG_TYPE]: The "paths[0]" argument must be of type string. Received undefined
      at new NodeError (node:internal/errors:405:5)
      at validateString (node:internal/validators:162:11)
      at Object.resolve (node:path:167:9)
      at SuiteContext.<anonymous> (file:///C:/Media/src/eleventy-plugin-pug/test/test-plugin-data-functions.js:19:41)
      at Suite.runInAsyncScope (node:async_hooks:203:9)
      at new Suite (node:internal/test_runner/test:773:24)
      at Test.createSubtest (node:internal/test_runner/test:386:18)
      at run (node:internal/test_runner/harness:208:28)
      at test.<computed> [as only] (node:internal/test_runner/harness:218:7)
      at file:///C:/Media/src/eleventy-plugin-pug/test/test-plugin-data-functions.js:18:10 {
    code: 'ERR_INVALID_ARG_TYPE'
  }

✖ GIVEN a minimal project and config (0.0357ms)
  TypeError [ERR_INVALID_ARG_TYPE]: The "paths[0]" argument must be of type string. Received undefined
      at new NodeError (node:internal/errors:405:5)
      at validateString (node:internal/validators:162:11)
      at Object.resolve (node:path:167:9)
      at SuiteContext.<anonymous> (file:///C:/Media/src/eleventy-plugin-pug/test/test-plugin-minimal-setup.js:43:37)
      at Suite.runInAsyncScope (node:async_hooks:203:9)
      at new Suite (node:internal/test_runner/test:773:24)
      at Suite.createSubtest (node:internal/test_runner/test:386:18)
      at run (node:internal/test_runner/harness:208:28)
      at test (node:internal/test_runner/harness:215:39)
      at SuiteContext.<anonymous> (file:///C:/Media/src/eleventy-plugin-pug/test/test-plugin-minimal-setup.js:42:2) {
    code: 'ERR_INVALID_ARG_TYPE'
  }

Aankhen added a commit to Aankhen/eleventy-plugin-pug that referenced this issue Apr 24, 2024
@Zearin
Copy link
Owner Author

Zearin commented May 4, 2024

Yeah, I’m still learning how to write tests from scratch. I’m much more used to tweaking existing test suites.

I left some more feedback on your PR.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants