I am using docker slaves for build via Docker plugin for jenkins. I have no issues with my builds but however in one repository we're passing TZ variable to jest as shown below for a particular test suite. That variable is not taking effect and causes to fail the test.
> @different/different-ui@1.6.0 test /home/jenkins/agent/workspace/ferent_CI_wtml_25hf0e_for_mahela
> TZ=Australia/Sydney jest --config jest.config.js
Test fails as shown below
PASS src/components/data-molecule/data-molecule.spec.tsx
PASS src/components/button/button.spec.tsx
PASS src/components/text-box/text-box.spec.tsx
PASS src/utils/cascade.spec.tsx
PASS src/components/widget/widget.spec.tsx
PASS src/components/clickable/clickable.spec.tsx
PASS src/components/tag/tag.spec.tsx
FAIL src/components/table-cell-date-value/table-cell-date-value.spec.tsx
��� <TableCellDateValue /> ��� cell convert the provided date time value correctly
Expected value "Aug 1, 2019 - 12:55 pm"
Received:
"Aug 1, 2019 - 2:55 am"
Message:
expected <TableCellDateValue /> to have text 'Aug 1, 2019 - 12:55 pm', but it has 'Aug 1, 2019 - 2:55 am'
HTML:
<span id={[undefined]} className={[undefined]}>Aug 1, 2019 - 2:55 am</span>
Difference:
- Expected
+ Received
- Aug 1, 2019 - 12:55 pm
+ Aug 1, 2019 - 2:55 am
I have tried few things to overcome this
tried to set timezone as given below How do I set a timezone in my Jest config?
Tried to export env variable TZ in bash_profile in docker file itself
RUN ["/bin/bash", "-c", "echo 'export TZ=Australia/Sydney' >> ~/.bash_profile"]
I'm not sure whether docker plugin uses an interactive shell or a non-interactive shell while connecting to the container.
So far all of these efforts were unsuccessful.