-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace local tests with E2E tests (#60)
* Rename fake-project to e2e-tests * Add e2e test runner * Add default rollup e2e test and run e2e in npm test * Add better logging for e2e tests * Only run test & default-webpack when running npm test * Throw error if can't find e2e package.json * Add more E2E tests * Remove rollup E2E tests * Add E2E test filtering * Add custom webpack E2E test * Add note about separate babel-loader for coverage * Run E2E tests using local directories Can rely on --preserve-symlinks-main flag when things get complicated (i.e. uninstalling karmatic's devDep on webpack) * Fix webpack-loader e2e test to display code-coverage * Run npm installs serially first, then run tests serially after * Add other tests to default e2e test * Rename e2e tests to begin with webpack- * Remove webpack devDep and remove local tests * Add some function comments * Ensure script exits with failure code if tests fail * Fix e2e test package.json names * Run test command separatedly So task fails if test fail * Ensure karmatic exits with error code if error is thrown * Use NODE_PRESERVE_SYMLINKS flag to fix E2E tests * Only use preserve symlinks flag when running tests, not when installing * Add comment explaining use of symlink env vars * Add back test:build and test:watch scripts * Remove `npm i` from `test:build` since it is redundant with `prepare` script
- Loading branch information
1 parent
50a4ee4
commit 6be5fa7
Showing
19 changed files
with
406 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "karmatic-e2e-webpack-custom", | ||
"description": "Test custom webpack config in karmatic using a custom Babel config", | ||
"private": true, | ||
"dependencies": { | ||
"@babel/core": "^7.10.3", | ||
"babel-loader": "8.1.0", | ||
"babel-plugin-transform-rename-properties": "^0.1.0", | ||
"karmatic": "file:../..", | ||
"webpack": "^4.44.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function box(value) { | ||
return { _value: value }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { box } from '../src/index'; | ||
|
||
describe('Box', () => { | ||
it('should have a __v property', () => { | ||
const boxed = box(1); | ||
expect('_value' in boxed).toBe(false); | ||
expect(boxed.__v).toBe(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module.exports = { | ||
mode: 'development', | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.jsx?$/, | ||
loader: 'babel-loader', | ||
options: { | ||
plugins: [ | ||
[ | ||
'babel-plugin-transform-rename-properties', | ||
{ rename: { _value: '__v' } }, | ||
], | ||
], | ||
}, | ||
}, | ||
], | ||
}, | ||
performance: { | ||
hints: false, | ||
}, | ||
devtool: 'inline-source-map', | ||
stats: 'errors-only', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "karmatic-e2e-webpack-default", | ||
"description": "Test default webpack config in karmatic. Mildly complex src implementation to verify coverage works", | ||
"private": true, | ||
"scripts": { | ||
"test": "cross-env NODE_PRESERVE_SYMLINKS_MAIN=1 NODE_PRESERVE_SYMLINKS=1 node ./node_modules/karmatic/dist/cli.js run", | ||
"test:watch": "cross-env NODE_PRESERVE_SYMLINKS_MAIN=1 NODE_PRESERVE_SYMLINKS=1 node ./node_modules/karmatic/dist/cli.js --headless false" | ||
}, | ||
"dependencies": { | ||
"karmatic": "file:../..", | ||
"webpack": "^4.44.1" | ||
}, | ||
"devDependencies": { | ||
"cross-env": "^7.0.2" | ||
} | ||
} |
File renamed without changes.
20 changes: 0 additions & 20 deletions
20
fake-project/test/index.test.js → ...test/webpack-default/test/combine.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import createWorker from 'workerize-loader!./fixture.worker.js'; | ||
|
||
let worker; | ||
export function getWorker() { | ||
if (!worker) { | ||
worker = createWorker(); | ||
} | ||
|
||
return worker; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { getWorker } from './index'; | ||
|
||
describe('demo', () => { | ||
it('should do MAGIC', async () => { | ||
let worker = getWorker(); | ||
|
||
expect(worker.foo).toEqual(jasmine.any(Function)); | ||
expect(await worker.foo()).toEqual(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "karmatic-e2e-webpack-workerize-loader", | ||
"description": "Test customer webpack loader testing in karmatic", | ||
"private": true, | ||
"dependencies": { | ||
"webpack": "^4.44.1", | ||
"workerize-loader": "^1.3.0", | ||
"karmatic": "file:../.." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.