You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, I am having problems loading fixtures from a folder.
The folder ./graphql/fixtures/ actually contains .yml but never be loaded in both CLI & Programmatically loading fixtures
📦fixtures
┗ 📜Customer.yml
> npm run fixtures load ./graphql/fixtures/ --dataSource=./dataSource.ts --sync --require=ts-node/register --require=tsconfig-paths/register
Connection to database...
query: SELECT * FROM current_schema()
query: CREATE EXTENSION IF NOT EXISTS "uuid-ossp"
query: SELECT version();
Loading fixtureConfigs
Resolving fixtureConfigs
Progress [██████████████████████████████████████████████████] 100% | ET
Database disconnect
loadFixtures('./graphql/fixtures')// never loads any files.
> npm run fixtures load ./graphql/fixtures/Customer.yml --dataSource=./dataSource.ts --sync --require=ts-node/register --require=tsconfig-paths/register
loadFixtures('./graphql/fixtures/Customer.yml')// loads only "Customer.yml" file as expected.
So then I cloned this repo and tried to execute tests:
gh repo clone RobinCK/typeorm-fixtures
npm i
npm run test
Then specific tests regarding Loader, Resolver will be failed.
Output result of `npm run test`
> typeorm-fixtures-cli@3.0.1 test
> nyc mocha "test/**/*.ts"
Builder
✔ should be build entity
✔ should be build and transformed entity
✔ should be processed entity
✔ should be call method
✔ should be processor not found
✔ should be invalid __call parameter
✔ should be resolved entity field as promised
Loader
1) should be loaded data from folder
✔ should be loaded data from file
✔ should be fail load
✔ should be no such file
2) should be invalid fixture config
Parser
✔ should be parsed object
✔ should be parsed array
✔ should be parsed deep object
✔ should be parsed deep array
✔ should parse `null` as `null`
EJS parser
✔ should be support
✔ should be not support
✔ should be parsed
Faker parser
✔ should be support
✔ should be not support
✔ should be number
✔ should be boolean
✔ should be string
✔ should be translated string
Parameter parser
✔ should be support
✔ should be not support
✔ should be parsed
✔ should be not parsed
✔ should be taken from process.env
✔ should throw on unknown env variable
✔ should prefer explicit parameters to env variables
Parameter parser
✔ should be support
✔ should be not support
✔ should be resolver
✔ should be resolver mask
✔ should be not resolver
Resolver
3) should be resolved fixtures
✔ should be resolved range fixtures
✔ should be resolved range reference
✔ should be resolved range fixtures
✔ should be resolved deep reference
✔ should be resolved mask reference
✔ should be resolved current
✔ should be resolved calculated current
✔ should be fail resolved current
✔ should be reference not found
✔ should be resolved with equal dependencies for wildcard
Fixtures Iterator
✔ should be sort and iterate fixtures
47 passing (67ms)
3 failing
1) Loader
should be loaded data from folder:
AssertionError: expected [] to have a length of 2 but got +0
+ expected - actual
-0
+2
at Context.<anonymous> (test\unit\Loader.test.ts:18:28)
at processImmediate (node:internal/timers:466:21)
2) Loader
should be invalid fixture config:
AssertionError: expected [Function] to throw an error
at Context.<anonymous> (test\unit\Loader.test.ts:94:92)
at processImmediate (node:internal/timers:466:21)
3) Resolver
should be resolved fixtures:
AssertionError: expected [] to deeply equal [ { parameters: {}, …(4) }, …(1) ]
+ expected - actual
-[]
+[
+ {
+ "data": {
+ "email": "{{internet.email}}"
+ "firstName": "{{name.firstName}}"
+ "lastName": "{{name.lastName}}"
+ }
+ "dependencies": []
+ "entity": "User"
+ "name": "user1"
+ "parameters": {}
+ }
+ {
+ "data": {
+ "description": "{{lorem.paragraphs}}"
+ "title": "{{name.title}}"
+ "user": "@user1"
+ }
+ "dependencies": [
+ "user1"
+ ]
+ "entity": "Post"
+ "name": "post1"
+ "parameters": {}
+ }
+]
at Context.<anonymous> (test\unit\Resolver.test.ts:19:32)
at processImmediate (node:internal/timers:466:21)
So then, I thought something is wrong in glob and downgraded to "glob": "^7.x", it works.
According to the glob changelog in 8.x
8.0
Only support node v12 and higher \ is now only used as an escape character, and never as a path separator in glob patterns, so that Windows users have a way to match against filenames containing literal glob pattern characters.
Glob pattern paths must use forward-slashes as path separators, since \ is an escape character to match literal glob pattern characters.
(8.0.2) cwd and root will always be automatically coerced to use / as path separators on Windows, as they cannot contain glob patterns anyway, and are often supplied by path.resolve() and other methods that will use \ path separators by default.
I also think adding tests in CI for multiple environments (especially Windows for this case) could catch this sort of environemnt-specific bugs and improve reliability.
Problem
Hey, I am having problems loading fixtures from a folder.
The folder
./graphql/fixtures/
actually contains.yml
but never be loaded in both CLI & Programmatically loading fixturesBut specifying the exact file just like below works. as well on the Programmatically loading fixtures.
So then I cloned this repo and tried to execute tests:
Then specific tests regarding Loader, Resolver will be failed.
Output result of `npm run test`
Cause
typeorm-fixtures/src/Loader.ts
Lines 22 to 36 in 86d1395
files
was empty array[]
so this line of code is cause:typeorm-fixtures/src/Loader.ts
Line 33 in 86d1395
So then, I thought something is wrong in glob and downgraded to
"glob": "^7.x",
it works.According to the glob changelog in 8.x
Then I made some changes, to avoid
\
path separator and use/
instead:The all tests passed and fixed.
I'll make a PR for this issue, so I appreciate if you take a look to it. :)
Your Environment
The text was updated successfully, but these errors were encountered: