From b898449cd2d53f80ca047a14b12b94c16fa51410 Mon Sep 17 00:00:00 2001 From: Vishal Shah Date: Wed, 25 Jan 2023 12:12:30 +0530 Subject: [PATCH] Adding Next.js article --- .../testing-nextjs-components.md | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 guide/component-testing/testing-nextjs-components.md diff --git a/guide/component-testing/testing-nextjs-components.md b/guide/component-testing/testing-nextjs-components.md new file mode 100644 index 00000000..7107877b --- /dev/null +++ b/guide/component-testing/testing-nextjs-components.md @@ -0,0 +1,37 @@ +--- +title: Next.js component testing +description: Learn how to do write and execute Next.js component tests in Nightwatch. +--- + + +### Overview +[Next.js][1], developed by [Vercel][2], is a framework built on top of React. NextJS component testing setup with Nightwatch is the same as React component testing setup. Next.js makes full stack web development easier by extending the latest React functionality. The Rust based Javacript tooling integrated into the framework makes the builds blazing fast. + +### Installation + +#### New Project +When you initiate a Nightwatch project using +
npm init nightwatch@latest
+ +select component testing and React.js and let Nightwatch handle the setup for you. + + +#### Existing Project +Follow the same steps as [React component testing installation][3] + +### Testing NextJS components +Simply mount the component using the `mountComponent('path_to_component_file')` command and write your tests like you would for any other test. + + +
NextJS component test
describe('Next.js test', function() {
+  it('NextJS component testing', async function(browser) {
+    browser
+        .mountComponent("/src/components/About.jsx")
+        .assert.textEquals("h1","About");
+  }); 
+}); 
+
+ +[1]: https://nextjs.org/ +[2]: https://vercel.com/ +[3]: https://nightwatchjs.org/guide/component-testing/testing-react-components.html#installation \ No newline at end of file