Comments (5)
@birtles Thanks for pointing out this issue, v3.3.1 was released with your fix!
from jest-dynamodb.
Thank you!
from jest-dynamodb.
@harazdovskiy could you please take a look? Likely a problem with export default
vs export
(just a guess)?
from jest-dynamodb.
Sorry again about the minimal bug report. I hope to have time to look into this tomorrow or the next day to provide more details.
from jest-dynamodb.
I think this comes down to:
const preset = require('./lib');
needing to specify .default
before re-exporting the result.
My working
For the validation warnings, the stack I get is:
at logValidationWarning (/home/birtles/project/node_modules/jest-validate/build/utils.js:101:11)
at Object.unknownOptionWarning [as unknown] (/home/birtles/project/node_modules/jest-validate/build/warnings.js:44:35)
at _validate (/home/birtles/project/node_modules/jest-validate/build/validate.js:81:17)
at validate (/home/birtles/project/node_modules/jest-validate/build/validate.js:118:41)
at normalize (/home/birtles/project/node_modules/@jest/core/node_modules/jest-config/build/normalize.js:645:65)
at readConfig (/home/birtles/project/node_modules/@jest/core/node_modules/jest-config/build/index.js:219:74)
at async readConfigs (/home/birtles/project/node_modules/@jest/core/node_modules/jest-config/build/index.js:404:26)
at async runCLI (/home/birtles/project/node_modules/@jest/core/build/cli/index.js:140:59)
at async Object.run (/home/birtles/project/node_modules/jest-cli/build/cli/index.js:155:37)
The options passed in to normalize
are:
{
transform: { '^.+\\.tsx?$': 'ts-jest' },
default: {
globalSetup: '/home/birtles/project/node_modules/@shelf/jest-dynamodb/lib/setup.js',
globalTeardown: '/home/birtles/project/node_modules/@shelf/jest-dynamodb/lib/teardown.js',
testEnvironment: '/home/birtles/project/node_modules/@shelf/jest-dynamodb/lib/environment.js'
},
testMatch: [ '**/*.test.ts' ],
modulePathIgnorePatterns: [ '.aws-sam', 'cdk.out' ],
moduleNameMapper: {
'@birchill/bugsnag-zero/lambda-context': '@birchill/bugsnag-zero/lambda-context-cjs'
},
rootDir: '/home/birtles/project'
}
Digging into readConfig
we are hitting this branch withconfigPath
being /home/birtles/project/jest.config.js
, and rawOptions
being the above object.
That's coming from calling requireOrImportModule
here:
The requires the config file here:
https://github.com/facebook/jest/blob/main/packages/jest-util/src/requireOrImportModule.ts#L22
applyInteropRequireDefault
is true so it ends up wrapping the object in { default: <config> }
before accessing the default
property anyway. No problem here.
The problem is why the config
file has the globalSetup
etc. members nested under default
.
Looking at my config file I have:
const tsPreset = require('ts-jest/jest-preset');
const dynamodbPreset = require('@shelf/jest-dynamodb/jest-preset');
module.exports = {
...tsPreset,
...dynamodbPreset,
testMatch: ['**/*.test.ts'],
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
modulePathIgnorePatterns: ['.aws-sam', 'cdk.out'],
};
Here tsPreset
is:
{ transform: { '^.+\\.tsx?$': 'ts-jest' } }
while dynamodbPreset
is:
dynamodbPreset {
default: {
globalSetup: '/home/birtles/project/node_modules/@shelf/jest-dynamodb/lib/setup.js',
globalTeardown: '/home/birtles/project/node_modules/@shelf/jest-dynamodb/lib/teardown.js',
testEnvironment: '/home/birtles/project/node_modules/@shelf/jest-dynamodb/lib/environment.js'
}
}
In jest-preset.js
where we have:
const preset = require('./lib');
module.exports = preset;
preset
is being resolved to:
{
default: {
globalSetup: '/home/birtles/10ten-server/node_modules/@shelf/jest-dynamodb/lib/setup.js',
globalTeardown: '/home/birtles/10ten-server/node_modules/@shelf/jest-dynamodb/lib/teardown.js',
testEnvironment: '/home/birtles/10ten-server/node_modules/@shelf/jest-dynamodb/lib/environment.js'
}
}
I'm way out of my depth when it comes to module loading but just going off the explanation here on this SO answer and digging into lib/index.js
, I wonder if we want to be doing:
const preset = require('./lib').default;
instead?
That seems to line up with this SO answer too.
If so, that would make b073618 the culprit.
Just changing:
const preset = require('./lib');
to:
const preset = require('./lib').default;
locally fixes it for me.
from jest-dynamodb.
Related Issues (20)
- Error: A JNI error has occurred, please check your installation and try again HOT 2
- Setup hangs when using custom endpoint. HOT 4
- How to use .cjs extension for config when using "module" type in package.json HOT 2
- Validation Error after updating to v3.3.1 HOT 2
- Tests fail when ran on CI/CD server, but work locally HOT 1
- Issue in globalSetup after upgrading to Node 18 HOT 2
- Running Jest now hangs on "Determining test suites to run..." HOT 18
- DynamoDB server doesn't start when running jest HOT 1
- Test suite failed to run caused by TypeError HOT 1
- Error: Invalid or corrupt jarfile DynamoDBLocal.jar HOT 5
- Test errors out at first use of typescript syntax
- Prototype Pollution Affecting fast-xml-parser package, versions <4.1.2 HOT 1
- UnrecognizedClientException HOT 7
- How can I use `jest-dynamodb` in a `nx` managed monorepo? HOT 2
- Warning "Jest did not exit one second after the test run has completed" out on Node v20 HOT 1
- Suggestion: Updating dynamo package
- Pinned @aws-sdk version bring ReDOS vulnerability CVE-2024-41818 HOT 1
- Version 3.5.0 on NPM doesn't correspond to a tag or a commit on the master branch
- Unable to initialize main class com.amazonaws.services.dynamodbv2.local.main.ServerRunner HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jest-dynamodb.