"Kim Jong Un is too smart and has far too much to lose, everything actually, if he acts in a hostile way," Trump tweeted in response to the unspecified test at the Sohae space launch center.
The announcement of Saturday's test came just hours after Trump said he would be "surprised" by any hostile action from the North, emphasizing his "very good relationship" with Kim.
Trump and Kim engaged in months of mutual insults and threats of devastation in 2017, sending tensions soaring before a diplomatic rapprochement the following year.
The pair have met three times since June 2018 but with little progress towards denuclearization. Pyongyang has set Washington a December 31 deadline to make new concessions to kickstart stalled talks.
"North Korea, under the leadership of Kim Jong Un, has tremendous economic potential, but it must denuclearize as promised," Trump tweeted. "NATO, China, Russia, Japan, and the entire world is unified on this issue!"
Writing that Kim had "signed a strong Denuclearization Agreement" at their June 2018 summit in Singapore," Trump warned: "He does not want to void his special relationship with the President of the United States or interfere with the U.S. Presidential Election in November."
A spokesman for North Korea's Academy of the National Defense Science said Saturday's "very important test" would have an "important effect" on changing the "strategic position" of North Korea, in a statement carried by the official KCNA news agency.
The statement did not provide further details on the test.
A senior US administration official earlier said Washington had seen reports of a test and was "coordinating closely with allies and partners."
Trump indicated that military action was still possible when he was asked about Pyongyang on the sidelines of a NATO summit in Britain this week.
North Korea fired back that if the United States used military force it would take "prompt corresponding actions at any level."
UN diplomats fear that North Korea will resume long-range nuclear or ballistic tests if no progress is made soon in talks with the United States.
Sohae, on North Korea's northwest coast, is ostensibly a facility designed for putting satellites into orbit.
But Pyongyang has carried out several rocket launches there that were condemned by the US and others as disguised long-range ballistic missile tests.
Following the Singapore summit, Trump said Kim had agreed to destroy "a major missile engine testing site" without naming the facility.
Kim then agreed to shutter the Sohae site during a summit last year with South Korean President Moon Jae-in in Pyongyang as part of trust-building measures.