This repository has been archived by the owner on Sep 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
303 additions
and
280 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,14 @@ | ||
# End to end tests | ||
|
||
End-to-end testing is a methodology used to test whether the flow of an | ||
application is performing as designed from start to finish. | ||
|
||
Tests here need to be run with a transpiled sources & a test folder ready to run | ||
|
||
```console | ||
npm run transpile | ||
npm run test-phenomic-theme-base:prepare | ||
npm run e2e:tests | ||
``` | ||
|
||
Otherwise you can just use `npm test` to run every tests. |
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,35 @@ | ||
import { | ||
exec, | ||
execOpts, | ||
phenomic, | ||
timing, | ||
maxTimeout, | ||
} from "./utils" | ||
|
||
it("should NOT throw if port is used", | ||
() => new Promise((resolve, reject) => { | ||
const app = require("express")() | ||
const server = app.listen(3333, (err) => { | ||
if (err) { | ||
reject(err) | ||
} | ||
|
||
const child = exec( | ||
`${ phenomic } start --open=false --devPort=3333`, execOpts, | ||
|
||
(err) => { | ||
if (err && !err.killed) { | ||
clearTimeout(timeout) | ||
reject(err) | ||
} | ||
} | ||
) | ||
|
||
// server need to be killed manually | ||
const timeout = setTimeout(() => { | ||
server.close() | ||
child.kill() | ||
resolve() | ||
}, timing) | ||
}) | ||
}), maxTimeout) |
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,30 @@ | ||
import { | ||
exec, | ||
execOpts, | ||
phenomic, | ||
timing, | ||
maxTimeout, | ||
} from "./utils" | ||
|
||
it("should NOT throw if a CLI flag is recognized", | ||
() => new Promise((resolve, reject) => { | ||
const child = exec( | ||
`${ phenomic } start --open=false --devPort=4000`, execOpts, | ||
|
||
// should die quickly... | ||
(err) => { | ||
if (err && !err.killed) { | ||
clearTimeout(timeout) | ||
reject(err) | ||
} | ||
} | ||
) | ||
|
||
// ...or be ok quickly | ||
// we assume it's ok and kill the process | ||
// we don't need the actual build | ||
const timeout = setTimeout(() => { | ||
child.kill() | ||
resolve() | ||
}, timing) | ||
}), maxTimeout) |
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,35 @@ | ||
import { | ||
exec, | ||
execOpts, | ||
phenomic, | ||
timing, | ||
maxTimeout, | ||
} from "./utils" | ||
|
||
it("should throw if a CLI flag is NOT recognized", | ||
() => new Promise((resolve, reject) => { | ||
const child = exec( | ||
`${ phenomic } start --open=false --lol`, execOpts, | ||
(err) => { | ||
if (err && !err.killed) { | ||
clearTimeout(timeout) | ||
const isUnknown = err.message.indexOf("Unknown argument") > -1 | ||
if (isUnknown) { | ||
resolve() | ||
return | ||
} | ||
console.log(err) | ||
} | ||
reject() | ||
} | ||
) | ||
|
||
// server need to be killed manually | ||
const timeout = setTimeout( | ||
() => { | ||
child.kill() | ||
reject("Test didn't finish before timeout") | ||
}, | ||
timing | ||
) | ||
}), maxTimeout) |
Oops, something went wrong.