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
Supports NPM 8 and convert tests from Mocha to Jest #1084
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a specific test scenario where NPM 8 is used (or when NPM < 8 is used) like we did for Serverless?
@j0k3r I've added tests, unfortunately, I'm not very used to the test framework used (I feel more comfortable with Jest). Also I think it would be nice to have end-to-end testing test cases. |
@moroine For e2e tests you may take a look at the testing tool |
@vicary in order to install @serverless/test I need to upgrade to As NodeJs 10 is deprecated, do we want to drop the support? I can just create some test projects within tests and try using |
I tried to add some integration test but didn't succeed as of now: #1019 I used the previous release of |
@@ -0,0 +1,21 @@ | |||
'use strict'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to be able to run the fixture in tests, we need to tweak some files (especially because they are copied over a temporary directory)
async function runServerless(options) { | ||
const runServerlessOptions = { | ||
command: 'package' | ||
}; | ||
|
||
const servicePath = await setupFixture(options.fixture); | ||
|
||
runServerlessOptions.cwd = servicePath; | ||
const SERVERLESS_DIR = path.join(servicePath, 'node_modules', 'serverless'); | ||
try { | ||
const result = await originalRunServerless(SERVERLESS_DIR, runServerlessOptions); | ||
result.servicePath = servicePath; | ||
return result; | ||
} catch (error) { | ||
error.servicePath = servicePath; | ||
throw error; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very similar to @serverless/test
but the issue with the original one is they:
- run
npm install
- execute
_setup
This cause 2 issues:
- Cannot fix relative paths
- Cannot use yarn
@j0k3r @vicary after a lot of tries & failures I managed to make the tests finally work but at a cost of huge changes... This PR adds end-to-end tests, but I had a lot of issues due to mocking modules in tests (fs, glob, ...) but for e2e we won't want to mock. It was working when running alone but not with the entire suite test. To fix this I had to remove Not sure if you're ok with this PR changing so much at once 🤔 |
@moroine Huge thanks for the effort! I personally don't mind huge changes, it just takes time to review, largely making sure existing tests are correctly ported. I'll take some time in the weekend for this. Note: We want to make sure coverage is not dropped, we temporarily disabled the drop protection for the v3 PR but for most cases it is still enforced. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job, really!
I'm not against switch from Mocha to Jest, I use jest on a daily basis.
__mocks__
folder should be added to .npmignore
We merged some PRs today. |
Co-authored-by: Jérémy Benoist <j0k3r@users.noreply.github.com>
@j0k3r I've rebase the changes |
Closed/reopen to re-trigger GitHub Actions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I've got a busy weekend, just a few tweaks and we are good to go.
Why did you link the issue #374? |
Because with |
Are we good to merge? |
What did you implement:
Closes #1083 #805 #374
How did you implement it:
peerDependencies
causing a lot ofWARNINGS: Could not determine version of module XXXX
. In this case, we can use directlypackage-lock.json
which has the same shape as thenpm ls
result.How can we verify it:
Todos:
Is this ready for review?: YES
Is it a breaking change?: NO