aboutsummaryrefslogtreecommitdiff
path: root/devtools
diff options
context:
space:
mode:
authorJamal Carvalho <jamal@golang.org>2021-02-16 14:47:23 -0500
committerJamal Carvalho <jamal@golang.org>2021-02-17 15:58:23 +0000
commit656f5f670ebce91e5385203caa34b801dfb28fbe (patch)
treee3facc9b2e033f7007b9b7bf87e38d416f6c5e4d /devtools
parent17f3512b1a564722bec86252ea535e13c4af2dc1 (diff)
downloadgo-x-pkgsite-656f5f670ebce91e5385203caa34b801dfb28fbe.tar.xz
devtools/config: jest config updates
Adds a setup file for e2e testing with jest. This will let us consolidate setup code common to all e2e tests. Change-Id: I7f0ee7316b67e91345f7e47e507b5fd93da773c8 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/292699 Trust: Jamal Carvalho <jamal@golang.org> Run-TryBot: Jamal Carvalho <jamal@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'devtools')
-rw-r--r--devtools/config/e2e-test-setup.ts3
-rw-r--r--devtools/config/jest.config.js16
2 files changed, 17 insertions, 2 deletions
diff --git a/devtools/config/e2e-test-setup.ts b/devtools/config/e2e-test-setup.ts
new file mode 100644
index 00000000..579dbe11
--- /dev/null
+++ b/devtools/config/e2e-test-setup.ts
@@ -0,0 +1,3 @@
+import { toMatchImageSnapshot } from 'jest-image-snapshot';
+
+expect.extend({ toMatchImageSnapshot });
diff --git a/devtools/config/jest.config.js b/devtools/config/jest.config.js
index 24caf2b3..34c90f59 100644
--- a/devtools/config/jest.config.js
+++ b/devtools/config/jest.config.js
@@ -1,5 +1,4 @@
-// eslint-disable-next-line no-undef
-module.exports = {
+let config = {
preset: 'ts-jest',
rootDir: '../../',
globals: {
@@ -9,3 +8,16 @@ module.exports = {
},
moduleFileExtensions: ['ts', 'js'],
};
+
+// eslint-disable-next-line no-undef
+const e2e = process.argv.includes('e2e');
+if (e2e) {
+ config = {
+ ...config,
+ setupFilesAfterEnv: ['<rootDir>/devtools/config/e2e-test-setup.ts'],
+ testEnvironment: 'node',
+ };
+}
+
+// eslint-disable-next-line no-undef
+module.exports = config;