E2E Test Automation Anti-Pattern: node_modules and package.json or alike
It results from bringing “Developer Mindset and Practice” to E2E Test Automation.
This is an article in the E2E Test Automation Anti-Pattern series.
Why do some software engineers create jokes about node_modules, like the one below?
Because they (JS engineers) don’t like it. One common pain is accidentally committing the node_modules
folder into the Git repository and pushing it up!
Of course, the solution is simple: add node_modules
in the .gitignore
file.
Like many JS developers/testers, I made this mistake too, more than once! In those moments, I often reflect on a line from my favourite movie, “Monsters Inc.”
It frustrates me when developing/maintaining E2E test scripts in JavaScript, as there is no such shenanigan (along with others) in Ruby. Today, I will talk about the annoying node_modules
in the context of E2E Test Automation.
Table of Contents:
· What is Node_Modules?
· You Don’t Need to Worry about this if you are using Ruby.
· A Case Study of Executing a simple @playwright/test test script
· Why package.json and node_modules are unnecessary for E2E Test Automation?
∘ 1. E2E Test Scripts Require a much smaller number of libraries
∘ 2. No need to be localized
∘ 3. The test automation libraries are generic and not specific to apps.
· How was this package management made into E2E Test Automation?
What is node_modules?
It is for library dependency management, to make a Node.js application to load dependent libraries. RubyGems (first release in 2004) is the best, simplest and most intuitive library management tool. NPM (first release: 2010) copied (I think) the idea from RubyGems, but was implemented poorly.
The node_modules
folder (under the application folder) contains all the dependent JS libraries, which can be huge, defined in the package.json
file. There is also the package.json.lock
file.
You Don’t Need to Worry about this if you are using Ruby.
Install the required libraries once.
gem install selenium-webdriver rspec
Then, you just run the test scripts in different test projects.
cd ~/whenwise-ui-tests; rspec spec/login_spec.rb
cd ~/clinicwise-ui-tests; rspec spec/emoji_spec.rb
I know some JS engineers would argue, “While there is no node_modules in Ruby, there are similar Gemfile and Gemfile.lock”. Yes. Read on.
Keep reading with a 7-day free trial
Subscribe to AgileWay’s Test Automation & Continuous Testing Blog to keep reading this post and get 7 days of free access to the full post archives.